Sort by multiple fields (with different directions)


#1

Is it possible to sort the search results by multiple fields? Imagine having some simple documents with fields “change date” and “title”. My search should now return the results ordered by “change date” descending (“latest first”) and then ordered by title.
If I read the docs right, a possibility could be using boosts, but this is really strange for such a common case.


#2

Hey Stefan,

Multi-field = multi-directional sort isn’t currently supported. I believe you can sort by multiple fields in a single direction, but precision can be hard to lock in.

For a multi-direction approach, the best suggestion would be to capture the top ≤100 results in a single page response [ex. descending by date], and then post-process the JSON response host side in order to affect the secondary directional sort.


#3

Thanks for your answer. Though its not the best solution we will do this.