Optimizing search requests for speed and relevance, score "margin"

I have a custom app using elasticsearch-py and my searches are way slower than the production app should be. Those queries include function_score with stored scripts side by side with bool should queries. And that's only half of the problem as I don't know how to accomplish base functionality too.

That base functionality means that major branch of my for now large and complex query should have at least predefined score and if it doesn't then that document doesn't qualify.

Let's say that major "branch" is a function_score and if it returns score greater or equal 0.5 then the search should continue to the next branch. The very next branch is a bool should query and it qualifies for every score greater than 20.0, and so on.

Is there any way I could limit score if it reaches some value? For example whole search could be done in one request with boost on major branch with value of 20 or so, but the problem is that second branch could have score for example 150.0 and I want it to count as it is just 20.0 (margin is 20). In combination with the perfect result of the major branch (1.0 script result boosted with 20) it qualifies the same as original result of 20.0 (that's not "truncated" from 150.0).

Another approach would be that the branches participate with the percentage. For example major branch score participate with 40% to the final result, second branch participate with 20% to the final score, and so on. Is there any way to accomplish that?

Please let me know if you want me to explain more (or simpler :slight_smile: ) what I want to achieve!

Best regards!

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