Gravatar for jlynch@sonusnet.com

Question by Jim Lynch, Nov 17, 2015 9:52 PM

Multiple facets using same data-field

Is there a way to create multiple facets using the same data-field ? The following only shows the first facet of "Trunking and Access".

            <div class="CoveoHierarchicalFacet" data-title="Product" data-field="@toipathname"
                data-delimiting-character="/"
                data-level-start="0" data-level-end="10"
                data-additional-filter='@toicategoryname=="Trunking and Access"'
                data-tab="TOI"></div>

            <div class="CoveoHierarchicalFacet" data-title="Product" data-field="@toipathname"
                data-delimiting-character="/"
                data-level-start="0" data-level-end="10"
                data-additional-filter='@toicategoryname=="NetX"'
                data-tab="TOI"></div>

            <div class="CoveoHierarchicalFacet" data-title="Product" data-field="@toipathname"
                data-delimiting-character="/"
                data-level-start="0" data-level-end="10"
                data-additional-filter='@toicategoryname=="SBC"'
                data-tab="TOI"></div>

Thanks Jim

1 Reply
Gravatar for mlaporte@coveo.com

Answer by Martin Laporte, Nov 18, 2015 2:45 AM

Yes. The trick is to assign each of them a different id through the data-id attribute. By default the name of the field is used as an ID, so several facets using the same field will share their selection, but if each one has a different ID they'll be completely independent.

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 18, 2015 9:47 AM

Thanks for the quick reply. I have added a data-id to each of the intended facets as such:

            <div class="CoveoHierarchicalFacet" data-title="NetX" data-field="@toipathname"
                data-delimiting-character="/"
                data-id="NetX"
                data-level-start="0" data-level-end="10"
                data-additional-filter='@toicategoryname=="NetX"'
                data-tab="TOI"></div>

            <div class="CoveoHierarchicalFacet" data-title="Trunking and Access" data-field="@toipathname"
                data-delimiting-character="/"
                data-id="Trunking_and_Access"
                data-level-start="0" data-level-end="10"
                data-additional-filter='@toicategoryname=="Trunking and Access"'
                data-tab="TOI"></div>

            <div class="CoveoHierarchicalFacet" data-title="SBC" data-field="@toipathname"
                data-delimiting-character="/"
                data-id="SBC"
                data-level-start="0" data-level-end="10"
                data-additional-filter='@toicategoryname=="SBC"'
                data-tab="TOI"></div>

But only the first facet is displayed (NetX). I changed the order and it consistently only shows the first facet. Am I missing something ?

Thanks Jim

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Nov 18, 2015 10:28 AM

What your "init" call looks like? Is it targeted to the first facet only:

$('div[data-title=NetX]').coveo('init');

Or is it more general on an element parent to all those facets?

$('#search').coveo('init');
Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 18, 2015 11:04 AM

I am not making any initialization calls. For the few pages we currently have, there are no 'init' calls. I am very new to VisualForce and the Coveo product.
Would that init call be done at the beginning of the VisualForce page between tags ?

thanks Jim

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Nov 18, 2015 11:55 AM

I'm not used to VisualForce either. I'll let @mlaporte answer this. It's probably done by Coveo for SalesForce automatically for you.

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Nov 20, 2015 8:21 AM

OK sorry for the delay, I finally had some time to take a look at this. In my tests, I have no problem in stacking several hierarchical facets on the same field, even without the data-id part (only then they all share the same state, as expected).

One thing that could yield the result you report is a JavaScript error somewhere during initialization. Can you check the browser console just in case?

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 20, 2015 9:44 AM

I have posted two questions, one about using hierarchical facets and this one about multiple facets but I have referenced both in the other post. Sorry for any confusion. For this post, I will only use CoveoFacet. Here is what I have in my VF page:

            <div class="CoveoFacet" data-field="@toipathname" data-id='id_SBC'
                data-title="SBC" 
                data-additional-filter='@toicategoryname=="SBC"'
                data-tab="TOI"></div>

            <div class="CoveoFacet" data-field="@toipathname" data-id='id_Trunking_and_Access"'
                data-title="Trunking and Access"
                data-additional-filter='@toicategoryname=="Trunking and Access"'
                data-tab="TOI"></div>

            <div class="CoveoFacet" data-field="@toipathname" data-id='id_NetX'
                data-title="NetX" 
                data-additional-filter='@toicategoryname=="NetX"'
                data-tab="TOI"></div>

@toicategoryname can be either 'NetX', 'SBC' or 'Trunking and Access'. I have verified that this field is set correctly. Therefore, data-additional-filter is working as expected.

I am expecting to see three facets but only see the first one. If I move the 'Trunking and Access' facet to the first position, then it will be the only facet to display. I see no errors in the Console when using Chrome or Firefox. In looking at the object used to perform the REST query, should I see some property that corresponds to the data-id that uniquely identifies the facet ?

Here is what I see in the request:

aq: "@toipathname=="/sbc/sbc_5x00_r3.1""
childField: undefined
context: undefined
cq: "@syssource==("Web - TOI") AND @sysfiletype==(pdf,doc,xls,ppt,pptx)"
debug: undefined
dq: undefined
enableCollaborativeRating: false
enableDidYouMean: true
enableDuplicateFiltering: false
excerptLength: 400
fieldsToExclude: undefined
fieldsToInclude: undefined
filterField: ""
filterFieldRange: undefined
firstResult: 0
Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 23, 2015 5:15 PM

On my VisualForce page, I click on a tab called TOI. My intention is to create three facets (SBC, Trunking and Access, NetX). Since I am using the same field for each facet, I thought that by using the data-additional-filter along with the data-id, I would be able to create all three facets. But I am only seeing the first facet. As mentioned earlier, regardless of the order of the facets, results only appear for the first facet. Am I missing something ?

Thanks Jim

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Nov 24, 2015 4:47 AM

Hey I missed your two last comments, since I need to expand the list to see them. Sorry about that.

This definitively looks odd. In the REST request body you should see a list of "group by" requests, and there should be at least one for each of your facets (with the same field names). Is that the case?

(typically I'd ask for a Fiddler trace so I can have a look, but you'd need to open a case with support for it to reach me)

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 24, 2015 12:10 PM

I have installed Fiddler and found this: https://developers.coveo.com/display/public/SupportKB/Gathering+Debug+Information+using+Fiddler Do I need to configure Fiddler for HTTPS decryption in order to get the information that would help ?

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Nov 24, 2015 1:03 PM

You can inspect the REST requests body from the network tab of your browser's developer tools (F12).

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 24, 2015 1:22 PM

Yes, have done that and emailed Mark an image of the output. Wasn't sure if Fiddler provided any additional information.

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Nov 25, 2015 8:03 AM

Um I haven't received any email. Also, my name is not Mark :)

My email is my username here @coveo.com

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 25, 2015 9:13 AM

Sorry Martin about the name confusion. Have sent the email with a screenshot of the request and response.

Ask a question