Gravatar for

Question by Arun Sharma, Jan 2, 2018 1:20 PM

How can I sort boosted result for Coveo for Sitecore?

Hi Team,

I have a couple of result on my search page that contains:

Bio, Service, Industry, News, Events, Publication etc.

We boost the result based on the template in the same sequence which I defined above.

News, Events, Publication have an Insight Date field, now we want to sort those based on the date field.

Kindly tell me the way how can we achieve the same or how we can sort boosted result only specific template items.


Arun Sharma

1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Jan 3, 2018 10:23 PM

With your current solution, you are sorting the results by index relevancy and are adding additional points to the results score based on their type (Bio, Service...) with boosting. As it is only a boosting, it does not ensure your results will be always sorted in that order. You could have a Publication result before a Bio result if the searched terms are found more often, found in titles or subtitles, found in bold, etc in the Publication document.

Now, you want the results of the News, Events, and Publication types to be boosted by Insight Date. As you are sorting by index relevancy, you will never be able to achieve precise sorting as explained above. What you would need to give a boost to simulate a date sort for those results is a Query Ranking Function (QRF). The expression needs to be a mathematical expression that returns a number greater than 0 for the desired order. If you want to simulate a descending date sort, it needs to return a lower number for old results and a larger number for recent results. So you would use the value of your Insight Date field with the available operators of the ExprTk library to calculate this number. Like substracting the value of the oldest result to your field value. Something like this should work where 2014/01/01 id the date of my oldest result.Of course you have to translate the field name with ToCoveoFieldName as well.

$qrf(expression:'@insightDate-2014/01/01', normalizeWeight: True)
Ask a question