-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Deserializing MatchQuery ZeroTermsQuery field fails if the source JSON comes from OpenSearch MatchQuery #1150
Comments
As you've noted for cases like This is something we should consider how to represent in the spec: https://github.com/opensearch-project/opensearch-api-specification/blob/19421f502740967e4d6df102f1c5765c53eaa010/spec/schemas/_common.query_dsl.yaml#L943 |
I love/hate regex. :) |
I agree with you though, this should likely be handled in the spec somehow but not sure there's a standard for that and not sure we want to hand-edit exceptions. It's easy enough to work around if documented, but let's at least discuss options. |
It looks like Jackson JsonP does support this with appropriate annotations. |
What is the bug?
The enum defined for the client uses lower case values for the
ZeroTermsQuery
enum:opensearch-java/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ZeroTermsQuery.java
Lines 38 to 42 in 08e7e65
However, this enum is defined on OpenSearch with traditional all-caps enum names:
As a result, a search query generated on OpenSearch can not simply transform its JSON into a client search request.
How can one reproduce the bug?
SearchSourceBuilder
:SearchSourceBuilder
to JSON:Note the value of
zero_terms_query
is all upper case.SearchRequest
object:What is the expected behavior?
In general, an OpenSearch
SearchSourceBuilder
can be serialized into JSON and then deserialized into an OpenSearch Java ClientSearchRequest
.In this particular case, the all-caps enum name should match case-insensitively rather than throwing an exception.
See, for example, how logical operators (such as the
OR
in this query) accept either all-upper or all-lower case:opensearch-java/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Operator.java
Lines 39 to 42 in 08e7e65
What is your host/environment?
Running this on OpenSearch 2.15 code, but it has not changed since pre-fork.
Do you have any additional context?
Relevant code block causing the issue on a feature branch:
https://github.com/opensearch-project/ml-commons/blob/feature/multi_tenancy/plugin/src/main/java/org/opensearch/ml/sdkclient/RemoteClusterIndicesClient.java#L230-L232
The text was updated successfully, but these errors were encountered: