Support named query scores in Hit.matchedQueries() - #2098
Open
lawofcycles wants to merge 4 commits into
Open
Conversation
matched_queries is now generated as Map<String, Double> instead of the generic JsonData fallback. A schema driven rule in the code generator detects the oneOf of a string array and a scalar value map and maps it to a typed map. The deserializer reads the object form as name to score and the array form as names with null values. include_named_queries_score is now sent as a query parameter rather than in the request body. The server enables the scored map rendering only from the query parameter, so sending the flag in the body returns names without scores. The request body property is ignored in the code generator so the generated client emits the query parameter. See opensearch-project/OpenSearch#22689 for the server behavior. Adds MatchedQueriesTest covering the array and object forms. Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
lawofcycles
requested review from
Bukhtawar,
VachaShah,
Xtansia,
madhusudhankonda,
reta,
saratvemulapalli and
szczepanczykd
as code owners
August 11, 2026 06:04
# Conflicts: # CHANGELOG.md
3 tasks
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change lets the client retrieve named query scores through the typed API. Hit.matchedQueries() is now generated as Map<String, Double> mapping each named query to its score, and include_named_queries_score is sent as a query parameter so the server returns the scored map.
On the response side, a schema driven rule in the code generator detects the oneOf of a string array and a scalar value map and maps it to a typed map. The deserializer reads the object form as name to score and the array form as names with null values. This replaces the generic JsonData fallback that the polymorphic matched_queries schema previously produced. The detection is generic and, against the current specification, applies only to Hit.matched_queries.
On the request side, include_named_queries_score is emitted as a query parameter. The request body property is ignored in the code generator on purpose, because the server enables the scored map rendering only from the query parameter. Sending the flag in the request body returns names without scores. See opensearch-project/OpenSearch#22689 for that server behavior.
matched_queries is typed directly instead of adding a separate scores field. This is a breaking change scoped to the 4.0 line, where matched_queries was already exposed as JsonData rather than List, so no existing typed usage breaks.
Issues Resolved
Closes #1805
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.