Elasticsearch .net conditional sort

Glad you got it working :smile:

Not for a range query, no. You could write a script query to do this but similarly to script sorting, the performance of the query would not be as good as using the range query, but the performance might be acceptable for your use case. You can write a compound query however that combines

  • a range query on shipment_date with a term query on the sale* _index (both as filter clauses in a bool query)

with

  • a range query on created_date with a term query on the order* _index (both as filter clauses in a bool query)

both as should clauses in a bool query. Here's something similar as an example.

1 Like