4

I've been looking over several sites and guides on Coveo's site, but I'm trying to get together a "definitive" answer that has everything needed. I'm trying to designate one of my custom fields as a sortable field, then change the sort order of my search results to use this field. This is using Coveo for Sitecore 4.0 (CES 7 on-prem).

In the Coveo.SearchProvider.Custom.config file, I added this line to designate my field as sortable: <fieldType settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" fieldName="DC Date" isSortable="true" sitecoreFormat="yyyyMMddTHHmmZ"/> - this was from https://developers.coveo.com/display/SitecoreV4/Making+a+Sitecore+Field+Sortable. I then rebuilt my indexes.

In my CSHTML file, in the Coveo.QueryEvents.buildingQuery call where I build my query, I added this line: args.queryBuilder.sortCriteria = "@Model.ToCoveoFieldName("DC Date") descending"; - this was from https://answers.coveo.com/questions/5745/how-to-sort-by-publishing-date, but the person setting it up is using a built-in Sitecore field it seems, and there didn't seem to be a final resolution to "did that work."

I've checked the Coveo sources for an answer but I'm not finding anything concrete, especially on the sortCriteria syntax or if it should be used in buildingQuery or in another method. I don't want it to be a default sort overall in Coveo, and I don't intend it to be part of a sorting component...this is for a specific implementation of the search view.

Thanks for any help.

EDIT: Here's my rendering parameter setup (see comments): Rendering Parameters

  • Coveo specific not Sitecore related – Pete Navarra Nov 11 '16 at 10:37
  • Do you intend this sort to be the default for that specific result list? If so, you can set the default sort field directly on your "Coveo Search" component (see Default Sort Options in developers.coveo.com/display/SitecoreV4/… ). – Jean-François L'Heureux Nov 11 '16 at 14:37
  • By default, a date or numeric field is always sortable and facet in the Coveo index. You shouldn't have to specify the field in the field map to be able to use it to sort. – Jean-François L'Heureux Nov 11 '16 at 14:38
  • You should first check the type of the field in your Coveo index to ensure it is really indexed as a Datetime. – Jean-François L'Heureux Nov 11 '16 at 14:39
  • I confirmed the field is a date/time field in the index. I went into the component and chose the base template for the various item types I'm calling, then chose the date field and "descending". I put an image of what I did in the issue...it doesn't appear to be doing anything, but I'm not sure if there's a cache involved. The items I'm using all derive from Document Base Type, not sure if it takes a derivation or has to be the actual template. – Ken McAndrew Nov 11 '16 at 14:57
1

By default, a date or numeric field is always sortable and facet in a Coveo index. You shouldn't have to specify the field in the field map to be able to use it to sort.

The first thing to check to troubleshoot is the type of the field in your Coveo index to ensure it is really indexed as a Datetime field.

Then, if you intend this sort to be the default for that specific result list, you should set the default sort field directly on your "Coveo Search" component (see Default Sort Options in https://developers.coveo.com/display/SitecoreV4/Search+Component+Properties).

In this configuration, the "Date" sort type always use the modified date of the Coveo indexed documents. If you want to sort by another date, you need to choose "Field" in the sort type dropdown and then select the custom date field you want to sort with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.