3

How do I index related or linked items in a certain page and then use UnderscoreJS and OOTB Coveo features to display those items underneath the parent page in the results?

Example of related or linked files

2
  • What about writing your own Computed Field? Nov 17, 2016 at 14:16
  • Harsh, Gatogordo, Justin, Alan and Dmytro Can you please explain how this is too broad? I guess JF got it right and provided a great solution to the issue. Nov 18, 2016 at 18:39

2 Answers 2

6

The result your are trying to achieve is called folding. It needs a few fields with special values to link parent and child results together. It also needs UI components to alter the search query and display the results. All of this is supported by the Coveo index, Search API and JavaScript Search Framework.

First, have a look at the required fields. If your related items are also Sitecore items, you will need to code your own Sitecore Computed Index Fields to fill those field values with the required information. If your related items are in an external system, it will be harder for you to fill the fields but doable. You will need to ensure your Coveo for Sitecore edition supports the type of external source you need. Enterprise editions include the Connector Framework (on-premises) or Push API (Cloud) for you to develop connectivity if no out of the box Coveo connector exists for your repository.

Then, you will need to add a Folding component in your search interface to alter the search query. And finally, a ResultFolding component in your result templates to display the pages and their media library items together.

While not Coveo for Sitecore specific, this blog post explains the process from A to Z.

5
  • Thank you very much JF. We are in the process of trying this solution and will let you know once we achieve our goal. Nov 18, 2016 at 14:01
  • Hi JF, just a couple clarifying questions ... 1) When we index a Parent Item (page) I'm assuming we are to put the page's ID in the filterField, and the parentField fields and a list of the Child Item IDs (the related document IDs) in the childField field. 2) Do we also need to put some values in these fields on the Child Items (the related documents)? If so, what? Is the parentField on the Child Items supposed to be set to the ID of the Parent Page? What if the Child Item is related to multiple parents? Nov 18, 2016 at 19:53
  • 1) I think you are right. But I think ChildField is not needed. 2) Yes you have to fill in those fields on the child items. FilterField will contain the page ID. ChildField will contain the document ID. ParentField is not needed I think. If the child item is related to multiple parents, folding cannot be used as the child item can only be returned once in the search results (no matter if the list is flat or folded). Nov 18, 2016 at 21:03
  • Thanks JF. In the case where we can have more than one parent item for a document how would you suggest we display them in the search result for the parent documents? Would we, perhaps, stick some Jason data in a computed field on the parent and parse it in the results? Nov 18, 2016 at 21:29
  • A child search result cannot have multiple parents in the Coveo search results. If you have to live with this constraint, I would recommend to: 1) Avoid folding and treat each parent and related document independently. 2) On the PDF/Doc documents, index all their parent Sitecore item IDs in a computed index field. 3) At query time, process the value of this field to compute the URLs of the items like the ResolveResultClickableUriProcessor in the coveoProcessParsedRestResponse pipeline. Store this value in a new field. 4) Display links to parents in a PDF/Doc result template. Nov 24, 2016 at 18:31
-1

Try creating a computed field for PDF and Word documents as shown here https://developers.coveo.com/display/public/SitecoreV4/Creating+a+Computed+Field+for+a+Referenced+Item

Then you can access the field property in the results template and will also be able to format/massage the clickuri for these documents.

3
  • 2
    Storing the content of the PDF/Word documents in a field is not a good practice and a very complex one. You shouldn't have to understand those file formats from withing Sitecore code to extract their text. Nov 17, 2016 at 20:07
  • I dont think that is what I was hinting at. I meant to store the path of the document.
    – xoail
    Nov 17, 2016 at 20:09
  • Ok, in this case it is simpler. But the content of the DOC/PDF documents aren't searchable which limit the possibility they would be found by the visitor. Also, the visitor will have no clue if the words he searched for are contained in the documents. Nov 17, 2016 at 20:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.