Gravatar for

Question by Lautaro Bonetto, Apr 30, 2015 4:52 PM

Can I overwrite the ranking using a parameter on the Rest Search API query?


I want to increase the weight of some result in base of the field where the searched word is. To do it, I'm querying a Coveo REST Search service. On CES we have a source indexing Sitecore items through a Sitecore connector. Each item has many fields from Sitecore.

As example, let's suppose all the documents on this Coveo source has 4 fields (A, B, C and D). Those fields are not part of the title. If the word typed by the user is on the field C, I want to show this document on the top.

I tried to use a query like this one, but it doesn't work: http://server/rest/search/?rankingFunctions=[{"expression":"@c=\"typed word\"","modifier":"200"}]

Is there a way to make it on the same query string?

Thanks so much! Lautaro

Gravatar for

Comment by Lautaro Bonetto, Apr 30, 2015 4:55 PM

The wiki syntax has removed some characters on the URL. This is the URL that I tried to use: http://server/rest/search/?rankingFunctions=[{"expression":"@c=\"typed word\"","modifier":"200"}]

2 Replies
Gravatar for

Answer by Jean-François L'Heureux, Apr 30, 2015 5:19 PM

A ranking function expression cannot have a modifier and must return a numerical value. That numerical value is the ranking value added to the result score (see Ranking Function).

What you are looking to do is named Query Ranking Expression (see $qre REST Search API Query Extension). Since your QRE will be different for each query given the typed words, you should add it to the advanced query (aq) query string parameter.


http://server/rest/search/?q=typed word&aq=$qre(expression:@c="typed word", modifier:'200')
Gravatar for

Answer by Simon, Apr 30, 2015 4:58 PM

Overriding it, not really. But you can add some weight using QRE:


Ask a question