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).
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.