Gravatar for mohit.dharma@gmail.com

Question by mohit264, Jun 19, 2017 5:29 AM

Coveo for Sitecore - Field value based Sorting

I have two Rich text fields in my Sitecore template. I would like to prioritize result based on heading tags in their values. Is it possible out of the box in Coveo Search or Do we need to write custom logic?

2 Replies
Gravatar for sbelzile@coveo.com

Answer by Sébastien Belzile, Jun 19, 2017 10:21 AM

Yes, you can use query ranking expressions (or QRE) for boosting.

Basically, for a given query, you can specify that you wish to boost its results by the value of a `modifier`.

In your case, you should get something like:

`$qre(expression:@myfield='MyTag', modifier:'1000')`

Gravatar for mohit.dharma@gmail.com

Comment by mohit264, Jun 28, 2017 12:34 AM

I have tried using this. it is throwing error as something goes wrong. Search started working when I change my boosting expression.

Errored Expression

where Summary field contains string <h2> add 100 to document score.

Corrected Expression

site.png

However this seems no effect on searching results. I have summary field where I have some heading content. Searching always give priority to item name over heading content in search results.

Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Jun 19, 2017 12:54 PM

Supposing your rich text fields are rendered on the page for those items and you are indexing the rendered HTML version of the items with the `HtmlContentInBodyWithRequestsProcessor`. The Coveo index automatically boosts these documents in the search results if the user searched terms are found in an HTML heading tag. Same if the terms are found in bold, underlined, italic, uppercase in the original HTML document.

You don't have to tweak anything to make it work.

Ask a question