Gravatar for

Question by abhisfortitude, Jun 8, 2015 5:01 PM

How does CES determine the precedence of items when no facet is selected

We have two collection: Legacy (contains indexed external content) and Sitecore Search Provider (contains indexed Sitecore Content).

We have Auto Trigger Query selected. By default when the Coveo Search page is rendered, the search results displays the Legacy contents first. We would like indexed items from Sitecore Search Provider to take precedence over indexed items from Legacy by default.

How can we achive it? Through Ranking mechanism ? How does the Coveo Search Service determines which collection items takes precedence over other collection items when no facet is selected?

Thank you.

1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Jun 8, 2015 5:50 PM

By default, when the sorting is by relevancy and no query is entered, documents are returned by their indexed date. The latest indexed document is returned first. Since there's no basic expression, all the documents have the same ranking score.

To alter this sort order, you may add a Query Ranking Expression (QRE) to the query only when it doesn't contain a basic expression (the q query string parameter). The QRE would boost documents from the "Sitecore Search Provider" collection by 10 points, bringing them before the other collections documents.

This can be done in JavaScript before the call to 'init':

Coveo.$('#search').on('doneBuildingQuery', function (e, args) {
    var queryBuilder = args.queryBuilder;
    if (queryBuilder.expression.isEmpty()) {
        queryBuilder.advancedExpression.add("$qre(expression:'@syscollection==\"Sitecore Search Provider\"', modifier:'10')");
Ask a question