OpenSearch icon indicating copy to clipboard operation
OpenSearch copied to clipboard

[Feature Request] add support for include_named_queries_score in msearch

Open jdddog opened this issue 4 months ago • 3 comments

Is your feature request related to a problem? Please describe

The include_named_queries_score parameter, which enables scores to be returned for named queries, can only be used with search, not msearch.

Describe the solution you'd like

For include_named_queries_score to be a parameter in msearch.

Related component

Search:Query Capabilities

Describe alternatives you've considered

No response

Additional context

No response

jdddog avatar Aug 19 '25 03:08 jdddog

@jdddog -- Checking the code, it looks like you can put "include_named_queries_score":true in the body of a search request. I just wanted to check if that's a valid initial workaround. The annoying thing is that you'd need to include it in the body of each of the many sub-requests of an msearch. Still, it could unblock you for now.

We have some examples of other msearch URL parameters being passed to the underlying search requests in this method. A recurring pattern there is that we read off URL parameters at the start of the method, then call the appropriate setters on all of the SearchRequest objects at the end of the method. In this case, you'd need to pass it down to the source() under the search request, like:

            if (includeNamedQueriesScores) {
                request.source().includeNamedQueriesScores(includeNamedQueriesScores);
            }

If you're interested in submitting a fix, this should be a pretty easy one.

msfroh avatar Aug 19 '25 20:08 msfroh

Thanks @msfroh, it looks like include_named_queries_score is only accepted as a query parameter for each search, if I put it in the body it is ignored and the scores don't come through (although there is no error).

Thanks for the examples of how the msearch URL parameters are passed through, I'm keen to submit a fix.

jdddog avatar Aug 19 '25 23:08 jdddog

Hey all, any updates on this issue? In my opinion, it is a broken behaviour when you pass "include_named_queries_score": true in the body, but the results don't include the scores. It blocks us from using msearch for our use case.

makarova avatar Dec 10 '25 10:12 makarova

Hey all, any updates on this issue? In my opinion, it is a broken behaviour when you pass "include_named_queries_score": true in the body, but the results don't include the scores. It blocks us from using msearch for our use case.

Hey @makarova I made a PR to implement it, but haven't heard anything.

@sandeshkr419 and @msfroh would someone be able to review it?

The documentation PR was merged, but the code to implement it wasn't, so the official docs say that it is supported, when it isn't.

jdddog avatar Dec 17 '25 00:12 jdddog

Hey -- sorry, I completely missed that PR. I'll take a look right now.

Please feel free to @ me repeatedly if I don't respond. It sometimes notifies my phone (like this one just did), which gets my attention.

msfroh avatar Dec 17 '25 01:12 msfroh

Thank you @jdddog and @msfroh for moving the feature request forward. Is there any chance that this change will be added to OpenSearch 3.1.x as a patch update? We're using OpenSearch in AWS and the latest version that is supported there is only 3.1.

makarova avatar Dec 17 '25 14:12 makarova

Thank you @jdddog and @msfroh for moving the feature request forward. Is there any chance that this change will be added to OpenSearch 3.1.x as a patch update? We're using OpenSearch in AWS and the latest version that is supported there is only 3.1.

I don't see this being backported to OpenSearch 3.1 in the open source project. In general, we only do patch releases for critical security, availability, or data loss issues. This should go out in the 3.5 release, though.

AWS does sometimes backport fixes to earlier versions, but you'd need to talk to AWS support about that. This Github repository is just focused on the open source project.

msfroh avatar Dec 17 '25 18:12 msfroh

Hey -- sorry, I completely missed that PR. I'll take a look right now.

Please feel free to @ me repeatedly if I don't respond. It sometimes notifies my phone (like this one just did), which gets my attention.

No worries, thanks for looking at it :)

jdddog avatar Dec 18 '25 09:12 jdddog