I used the hybrid query as given in the documentation and it works fine when used independently.
I would like to combine Hybrid query with the function_score query as below:
Currently this does not return the normalised scores. The expectation here is that the normalised scores returned from hybrid query are later altered based on some other queries defined in function’s array.
How can Hybrid Query be combined here?
This won’t be possible with hybrid query because how hybrid query works.
Hybrid query clause should not be wrapped inside other query clauses. As main aim if hybrid query clause is to run calculate scores of queries independently and then normalize and combine at coordinator.
Is there any other way to achieve this? Currently no boostings can be applied if we try to use hybrid query which is a requirement.
Can this be considered as a feature enhancement.
The way you should be thinking about ‘hybrid’ query clause is it takes a list of queries that are executed separately on the shards and the scores are finally normalized and combined at coordinator.
So its more like you ran X separate queries against Opensearch and then normalized and combined scores in your application.
For your question, ideally the function score queries should be wrapped inside hybrid query clause.
Can you share an example.
Also if we wrap function scores inside hybrid query will the functions be applied on top of bm25+knn query’s normalised scores?
Also if we wrap function scores inside hybrid query will the functions be applied on top of bm25+knn query’s normalised scores?
It depends how you are creating function score query. This is a simple example I can come up with above provided query. Now you can boost the text match query how ever you want. At the end of the day what will happen is text and vector search queries will be executed separately and their scores will be normalized and combined at coordinator node.
Changing the size and k does impact the result count.
I wanted to show results using pagination for which I have been using from and size parameters.
Setting from:0 and size: 10; returns 10 results and total value as 50.