I am trying to sort Elasticsearch index on a date field in asc order. I have two conditions which I need to take care of while sorting.
All past dates should be considered as today's date. This matters since I am sorting on multiple fields.
All null values should be at the end.
I went through different suggestions of using function_score and script_score. I am new to Elasticsearch and I am unable to make that work for my usecase
So my query without applying any of above conditions look like this.
For the "null values should be at the end" thing you probably want the missing support from sorting.
For the date rules maybe you want script based sorting? It sounds like you have some rules about how you combine dates, or at least how you clamp their values. If you use script based scoring you'll have to pass now in as a parameter to the script. We intentionally don't expose that at the moment. Also, I'm not sure how script based scoring combines with the field scoring. That is a thing to experiment with.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.