Gravatar for jlynch@sonusnet.com

Question by Jim Lynch, Nov 16, 2015 10:18 PM

How to use a Hierarchical Facet to display directories from Web source

I was hoping to use the CoveoHierarchicalFacet class to list facets based upon the directory structure on the Web source.

The three parent directories are SBC, NetX and TrunkingandAccess. Is there a way to use the CoveoHierarchicalFacet class to expand/collapse the subdirectories under the parents ?

Here is the section from the VisualForce page:

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

Here is what I would like the facets to look like:

SBC
  |
  |  --> SBC_5x00_R1.0
     --> SBC_5x00_R1.1_1.2
     --> SBC_5x00_R2.0

Trunking_and_Access
   |
   |  --> Release_8.x
      --> Release_8.x/Release_8.0/Access_8.0
   |  --> Release_9.x
      --> Release_9.x/Release_9.3/PSX
      --> Release_9.x/Release_9.3

Here is the directory structure on the Web server:

./SBC
./SBC/SBC_5x00_R1.0
./SBC/SBC_5x00_R1.1_1.2
./SBC/SBC_5x00_R2.0
./SBC/SBC_5x00_R2.1
./SBC/SBC_7x00
./NetX
./Trunking_and_Access/Release_8.x
./Trunking_and_Access/Release_8.x/Release_8.0/Access_8.0
./Trunking_and_Access/Release_8.x/Release_8.0/Trunking_8.0
./Trunking_and_Access/Release_8.x/Release_8.0
./Trunking_and_Access/Release_8.x/Release_8.1/EMS
./Trunking_and_Access/Release_8.x/Release_8.1/Access_8.1
./Trunking_and_Access/Release_8.x/Release_8.1
./Trunking_and_Access/Release_8.x/Release_8.2/Access8.2/ASX_8.1_Feature_TOI/ASX_8.1_Feature_TOI
./Trunking_and_Access/Release_8.x/Release_8.2/Access8.2/ASX_8.1_Feature_TOI
./Trunking_and_Access/Release_9.x/Release_9.0/DSI_9.0
./Trunking_and_Access/Release_9.x/Release_9.0/EMS_9.0
./Trunking_and_Access/Release_9.x/Release_9.0/GSX_9.0
./Trunking_and_Access/Release_9.x/Release_9.0/PSX_9.0
./Trunking_and_Access/Release_9.x/Release_9.0/VAS_9.0
./Trunking_and_Access/Release_9.x/Release_9.0
./Trunking_and_Access/Release_9.x/Release_9.1/EMS
./Trunking_and_Access/Release_9.x/Release_9.1/Netscore
./Trunking_and_Access/Release_9.x/Release_9.1/Platform
./Trunking_and_Access/Release_9.x/Release_9.1/PSX
./Trunking_and_Access/Release_9.x/Release_9.1/SGX4000
./Trunking_and_Access/Release_9.x/Release_9.1/Training_Videos
./Trunking_and_Access/Release_9.x/Release_9.1
./Trunking_and_Access/Release_9.x/Release_9.2/DSI
./Trunking_and_Access/Release_9.x/Release_9.2/EMS
./Trunking_and_Access/Release_9.x/Release_9.3/PSX
./Trunking_and_Access/Release_9.x/Release_9.3
./Trunking_and_Access/Release_9.x
./Trunking_and_Access

Thanks for any ideas.

Jim

1 Reply
Gravatar for mark.angus@sitesystems.ca

Answer by mark, Nov 17, 2015 4:11 PM

Hi Jim, did you trying breaking down the path structure like the instructions in this page https://developers.coveo.com/display/public/JsSearch/HierarchicalFacet+Component ? You have to break it apart exactly like the page says then index the structure in the @toipathname on the document. You might have to do it in a custom Converter in the post conversion script.

Hope this helps.

Mark

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 18, 2015 10:44 AM

Hi Mark,

Thanks for the reply.

Yes, I did find that page earlier and have rebuilt the index. Perhaps I am misunderstanding how this class works. In my directory structure above, each of the three parent directories (TrunkingandAccess, NetX and SBC) may have one or more subdirectories which correspond to product releases.

Does each document in the directory structure require a field that then identifies the relationship to its parent ? In the page you referenced, it states the following:

The document text1.txt would need to have a field with the following format:
@field : c; c|folder1; 

Does this mean that each document in my directory ./Trunking_and_Access/Release_8.x/Release_8.2/Access8.2/ASX_8.1_Feature_TOI would have to have the following line added ?

@toipathname: Release_8.x/Release_8.2/Access8.2/ASX_8.1_Feature_TOI

Thanks Jim

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Nov 18, 2015 12:00 PM

It means that each document in your ./Trunking_and_Access/Release_8.x/Release_8.2/Access8.2/ASX_8.1_Feature_TOI directory must have a field with this exact format and data:

@toipathname: Trunking_and_Access;Trunking_and_Access|Release_8.x;Trunking_and_Access|Release_8.x|Release_8.2;Trunking_and_Access|Release_8.x|Release_8.2|Access8.2;Trunking_and_Access|Release_8.x|Release_8.2|Access8.2|ASX_8.1_Feature_TOI
Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 18, 2015 12:19 PM

Thanks for the clarification. Then I do not want to use that class. Is there a way to present the Facets in a hierarchical manner that reflects the directory structure ? I guess you can think of this as being a hierarchy of facets. May not be possible but just thought I would ask. My alternative is to create a Facet for each parent directory (Trunking and Access, SBC and NetX). This is related to my other question about 'data-id'. I'll wait for Mark to respond.

Thanks again, Jim

Gravatar for mark.angus@sitesystems.ca

Comment by mark, Nov 18, 2015 1:07 PM

Hi Jim, you could break down the directory structure as individual paths and try using the facets 'depends on' option. https://developers.coveo.com/display/public/JsSearchV1/Facet+Component#FacetComponent-dependsOn

The easiest way though is to parse out the directory structure and format it c; c:|folder1|… and set it in the @toipathname field per indexed document. This can be done using a custom converter. https://onlinehelp.coveo.com/en/ces/7.0/administrator/aboutnetconversion_scripts.htm

Hope this helps.

Mark

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 18, 2015 1:55 PM

Mark,

I seem to have hierarchical facets working even though i have not modified any files in the source. Here is an example of a toipathname: /Trunking and Access/9.x/9.3/PSX

What isn't working is the data-id. I am only seeing the first facet . This is related to my other question about multiple facets.

Here is a snippet of my page:

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

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

Regards Jim

Gravatar for mark.angus@sitesystems.ca

Comment by mark, Nov 18, 2015 2:06 PM

Hi Jim, the data-id field just specifies a unique identifier for the facet. Remember facets are built from results. If your results and the corresponding field @toipathname are not formatted correctly, the facet will use default behaviour and split the values by semicolon. The facet may have been only able to parse out the first value after split by ';'.

Hope this helps.

Mark

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 19, 2015 8:59 AM

Hi Mark,

I thought that by using data-additional-filter and giving each facet a unique ID that i could create three facets even though I was using the same data-field. The @toipathname will have values such as:

/NetX /Trunking and Access/3.x /Trunking and Access/8.x/8.4 /Trunking and Access/6.x/6.3.5 /SBC/SBC5x00R4.0/Security

Are these properly formatted ?

Thanks Jim

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 19, 2015 6:10 PM

Mark,

Do you see any problem with the way I defined the three facets above ?

Thanks Jim

Gravatar for mark.angus@sitesystems.ca

Comment by mark, Nov 20, 2015 9:00 AM

Hi Jim, you shouldn't need more that one CoveoHierarchicalFacet if you parse and place the correct document path format in the document @toipathname. If you want to have more that one facet, just use a regular facet. The Hierarchical facet should work if you parse the document path in the format demonstrated above by Jean-François.

Hope this helps.

Mark

Gravatar for jlynch@sonusnet.com

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

Hi Mark,

I am able to get a Hierarchical Facet to work without having to modify the files in the source using the same VF code as was posted above. Is there a way to post a picture of the page so that I can demonstrate ?

Thanks Jim

Gravatar for mark.angus@sitesystems.ca

Comment by mark, Nov 20, 2015 10:14 AM

Hi Jim, You can probably use the questions tool to link and image. How do you get the path information into your @toipathname field?

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 20, 2015 10:25 AM

I don't have enough "reputation" points to add an image.

I use a custom script to populate both @toipathname and @toicategoryname.

From the Salesforce page when clicking ALT and left mouse click twice, I can see the Coveo properties. Here is an example of the two that I created:

@toicategoryname
    Trunking and Access
@toipathname
    /Trunking and Access/9.x/9.1/Training_Videos
Gravatar for mark.angus@sitesystems.ca

Comment by mark, Nov 20, 2015 11:00 AM

Hi Jim, your directory should be index in the CES Collections Source. During that indexing is when the @toipathname should be calculated and set using the conversion script. The source should be configured to index your directory. On the page, the facet should be wrapped inside a div with id = 'search' which the Coveo reset search endpoint uses to build your results. The facet uses the search component to build its facet values (from the results).

I am not sure if I understand how you are setting the directory paths without all of the above mentioned configuration.

Let me know.

Mark

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 20, 2015 11:35 AM

Mark,

I created the 'Web - TOI' source and created the two custom fields @toipathname and @toicategoryname. They get populated by the conversion script when the index is built. The source indexes the URL https://toolbox.sonusnet.com/TOI. I am comfortable that the indexing and populating of the fields is working correctly.

On our VisualForce page, in addition to the creation of the facets, I have created the TOI tab using this:

                <a class="CoveoTab"  data-id='TOI' data-caption='TOI'
                    data-expression='@syssource==("Web - TOI") AND @sysfiletype==(pdf,doc,xls,ppt,pptx)'
                    data-icon="coveo-sprites-documentType-case"></a> 

This seems to work fine.

Here is what I currently have for my three facets:

            <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>

Each is wrapped in a div. Should each div also have "id='search'" like:

            <div id="search" class="CoveoFacet" data-field="@toipathname" data-id='id_Trunking_and_Access"'

I have tried that as well.

Thanks Jim

Gravatar for mark.angus@sitesystems.ca

Comment by mark, Nov 20, 2015 11:44 AM

Hi Jim, it should look like the snippet below: "<div id='search' class='CoveoSearchInterface' data-first-loading-animation-selector='#coveo-first-loading-animation'> ¨K0K <div class='coveo-results-section'> <div class='coveo-facet-column'> <div> <div class='CoveoHierarchicalFacet' data-title='Subjects:' data-caption='Subjects' data-field='@subjectnames' data-allow-toggling-operator='false' data-number-of-values='200' data-show-icon='true' data-tab='References' data-include-in-omnibox='false' data-injection-depth='20000' id='subjects_facet' data-id='subjects_facet' data-enable-settings='false' data-enable-facet-search='false' data-use-and='false' data-level-start='0' data-enable-more-less='false' data-delimiting-character='|'> </div> </div> </div>" Let me know.

Mark

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Nov 20, 2015 11:54 AM

Cannot see the snippet :-( You can email it to me at jlynch@sonusnet.com if that would be easier.

Gravatar for mark.angus@sitesystems.ca

Comment by mark, Nov 20, 2015 11:59 AM

Hi Jim, If you want to use multiple facets, you could investigate the facet depends on functionality. https://developers.coveo.com/display/public/JsSearchV1/Facet+Component#FacetComponent-dependsOn

Hope this helps.

Mark

Ask a question