Gravatar for fcote@coveo.com

Question by fcote, Apr 9, 2015 11:20 AM

How to specify the order in which the search results will be displayed

How do I set a specific order for search results with Coveo for Sitecore? For example, let's say I have pages that represent classes and I would like my content manager to define in which order these classes would be displayed after a search for a specific query.

Gravatar for dennis.augustine@techguilds.com

Comment by Dennis Augustine, Apr 9, 2015 12:07 PM

Can I do this using boosting? How do I create a boosting value that's based on a field value? Is that via a pipeline to set the the query ranking values in the index? I thought I saw something like that in training.

Gravatar for lbergeron@coveo.com

Comment by Luc Bergeron, Apr 9, 2015 1:22 PM

Yes of course. With the enterprise edition, you can configure the boosting rules directly from the Sitecore UI. In the free edition, you must create the query ranking expressions programmatically using the JavaScript search framework.

2 Replies
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Apr 9, 2015 1:59 PM

Suppose you have only classes in a search page and you want the content manager to choose the display order.

You can:

  1. Add an "search order" numeric field to your classes template.
  2. Configure this field to be a sort field in the Coveo.SearchProvider.config file "fieldMap" section with the isSortable="true" attribute.
  3. Let the content manager fill the field on the classes items with desired numbers.
  4. Either initialize the JavaScript UI sort in JavaScript to sort on this field or add a sort component on this field to the search page by the Page Editor (the sort component must be the only sort component of the page to be selected as the default sort or the page).
Gravatar for dennis.augustine@techguilds.com

Comment by Dennis Augustine, Apr 9, 2015 2:07 PM

Thank you. This is also a good way to manage the use case. :)

Gravatar for dennis.augustine@techguilds.com

Comment by Dennis Augustine, Apr 23, 2015 1:26 AM

I have set a computed field to isSortable="true" in the config and see it being set in the index but when it's selected as the sort field for the search view I get a "InvalidSortField" error. What causes this? How do I correct it?

Gravatar for lbergeron@coveo.com

Answer by Luc Bergeron, Apr 9, 2015 1:16 PM

It is possible to do what you want with boosting rules (aka. Query Ranking Expressions). You will need to configure one rule per item you want to "place" in the result list, then assign different weight to each rule. The highest the weight, the higher the result will appear.

More information is available here: https://developers.coveo.com/display/SC201504/Inserting+and+Customizing+a+Search+Interface+Component

You can also do it programmatically with the JavaScript search framework. It is documented here: https://developers.coveo.com/display/JsSearch/Using+Query+Ranking+Expressions

I hope this helps

Gravatar for dennis.augustine@techguilds.com

Comment by Dennis Augustine, Apr 9, 2015 2:08 PM

Thank you. That's a good option.

Ask a question