Gravatar for chris.weiss@rbaconsulting.com

Question by chrisweiss, Sep 22, 2016 3:51 PM

Coveo search sorting not working

(I'm using Coveo for Sitecore 4.0, June release, with Sitecore 8.1 Update 2)

We have a couple pages where we have a search view that requires the results be sorted by the publish date (a field on the item, not the Sitecore Publish Date).

The problem we're running into is that it seems to only sort by relevancy, not by field. In fact, any changes we make to the sort variables seem to have any effect, like our changes are being overwritten somewhere.

Here's the part of the code where we're updating the sort options:

CoveoForSitecore.componentsOptions = @(Html.Raw(Model.GetJavaScriptInitializationOptions()));
CoveoForSitecore.componentsOptions.defaultSortType = "Field Descending";
CoveoForSitecore.componentsOptions.defaultSortField = "@(Model.ToCoveoFieldName("Publish Date"))";
CoveoForSitecore.componentsOptions.defaultSortCriteriaNoSpace = "FieldDescending";
CoveoForSitecore.componentsOptions.defaultSortCriteriaLowercase = "field descending";

What am I doing wrong? Is there another way I should be doing this? I've tried modifying sortCriteria in queryBuilder as well, with no effect.

1 Reply
Gravatar for sbelzile@coveo.com

Answer by Sébastien Belzile, Sep 22, 2016 4:22 PM

In Coveo for Sitecore, default sorting is fronted on the Coveo Search component. See Default Sort Options sections on this page.

I think the problem is that to code of these options is overriding your code.

Gravatar for chris.weiss@rbaconsulting.com

Comment by chrisweiss, Sep 22, 2016 4:57 PM

Yeah, just setting the options in the Sitecore UI seemed to do it. I thought I had tried that before, but maybe we just had our Content Data fields misconfigured before. Thanks!

Ask a question