I would like to accomplish the following with a query:
1.) Perform a complex query that calculates a score for each matched document
2.) Rescore top N documents using a cosineSimilarity function for the dense_vector field type
3.) Combine the original score from the complex query with the cosine similarity according to the function: Math.log10(original_score) * cosineSimilarity_score.
I have been able to get the desired effect in two ways, but both are inefficient.
The first is to duplicate the entire original query in the query portion of the function score query in the rescoring. This seems pretty inefficient especially when the number of postings lookups is high.
The second is to wrap the original query with a function score query that uses a script score to apply the Math.log10 to every matched document which requires iterating through all the results rather than just top N.
Are there better alternatives that I haven't considered?