How to give more importance to recent dates within a certain range?

Hi,
I wanted to know whether it is possible to sort queries by most relevant within a specified range.
For example, lets take three scores that have been returned by a query.
Doc 1 = 85.1 - Date = 2 March 2020
Doc 2 = 84.2 - Date = 9 March 2020
Doc 3 = 83.8 - Date = 1 March 2020

In this case, all the three are within a range of +1 to -1 of each other. Normally this will get returned in the order Doc 1, Doc 2, Doc 3. I want it to return as Doc 2, Doc 1, Doc 3.
How do I do that?

I know we can sort by date, but I want it only for a certain range(in this case -1 to +1).
Any help will be appreciated. Thanks!

Have you tried the distance feature query?

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-distance-feature-query.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.