Hello Elasticsearch community,
When serving a given search query, our service is computing and using proximity score for each document in our index relative to the given query. This we currently implement by invoking the cosineSimilarity function inside a script_score section. We also make use of the min_score parameter in the query. We then sort the results by _score which is the very same proximity our query computes.
We have a variant of that query in which _score is actually the proximity score multiplied by a time decay. This also works just fine using ES' native support for decay functions.
However, we would also like to offer the flexibility to filter on minimum proximity score, and then sort by the decayed score. Is there a way to achieve that in a single query? Is there a way for our query to emit two different named computed scores, as in _proximity and _decayedProximity? I see only one such placeholder - _score - which we can compute to be either the raw proximity or the decayed one. But could we also have both? Could we compute multiple values from our script and assign them to different temporary/derived document fields, which we would then refer to from the sort section?
Right now the only way to implement our requirement we can think of is to use ES for the raw proximity score, and then additionally compute the decayed proximity for each returned document in our own service, and then perform the sorting in the service again. It would be really elegant if we could have ES do all that for us from a single query.
Thank you,
Krum.