Conditional sorting

I need to be able to sort content based on multiple fields. Sometimes a content has a title and an optional short title. The functionality I need would be to sort the result with short title if it exists, or else with title.

Elastic search can use a script for conditional sorting. Would it be possible to let us use that functionality?

2 Likes

I have hit on this problem multiple times myself. It would be great to be able to pass in a code script to sort results!

1 Like

Hello @odadoda,

Have you tried using Query DSL? It has exists expression to check if a field has a value and built-in sorting capabilities.

1 Like