elasticsearch custom scoring based on date field
It would be the best if you can use function score query There is a script type function there -
{ "query": { "function_score": { "query": { // Your query //}, "function": [ { "script_score": { "lang": "groovy", "script": "doc['dateA'].value - doc['dateB'].value" } } ], "boost_mode": "replace" // Remove score from query and replace it with the score from script } }}