Gravatar for jschjolberg@awareweb.com

Question by jschjolberg, Mar 30, 2015 4:16 PM

Can you specify multiple sortField options?

I am specifying the sortCriteria and sortField for my search like this:

$('#search").on("buildingQuery", function(e, args) {
  args.queryBuilder.sortCriteria = "FieldDescending";
  args.queryBuilder.sortField = "@MyField";
});

I'm wondering if you can specify more than one sortField - so it will sort first by one field and then sort those sorted results by another field. Is this possible?

Thanks!

1 Reply
Gravatar for topazahmed@gmail.com

Answer by topaz, Feb 3, 2016 6:47 PM

AVAILABLE IN: JUNE 2015 RELEASE

Multiple sort criteria can be specified by separating them with a comma (ex: @foo ascending, @bar descending). Multiple sort criteria only work when sorting by date or using custom fields. It is not possible to mix Relevancy and sorting by a field.

from: https://developers.coveo.com/display/public/SearchREST/Query+Parameters

Gravatar for topazahmed@gmail.com

Comment by topaz, Feb 3, 2016 8:32 PM

Though the instructions are clear I could not get it to work myself. an example from a guru would be nice.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 4, 2016 10:36 AM

First, are you using the June 2015 release or later of the Coveo Search API (8.0.715+)?

Can you post the code you tried?

Gravatar for topazahmed@gmail.com

Comment by topaz, Feb 4, 2016 10:51 AM

Go it working. Something like this works

args.queryBuilder.sortCriteria = "@date descending, @title ascending";
Ask a question