-
Notifications
You must be signed in to change notification settings - Fork 192
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] Unable to deserialize SearchRequest with _source field as an array #1087
Comments
Indeed, looks like arrays of fields aren't properly deserializing. I fixed the spec in opensearch-project/opensearch-api-specification#430 and opened opensearch-project/documentation-website#7748 for the docs.
All these work:
@chanon-onman Add a (failing) unit test? Want to try to fix it? |
Thank @dblock for help looking into this. I can try fix it but I'm not sure if I can do it correctly or not. Can you help guide me? Do you have sample PR that does similar things? |
I would start by seeing if the code generator that @Xtansia recently added would just do the right thing and add support for this after opensearch-project/opensearch-api-specification#430 is merged. |
@dblock I run following command and got the below error, not sure how to fix it? Do you a document how to run codegen properly?
|
@Xtansia ^ |
I can run codegen successfully when building opensearch-openapi.yaml locally from opensearch-api-specification commit e1cd369. |
I kicked https://github.com/opensearch-project/opensearch-java/actions/runs/10050371147, and it failed, Care to open an issue for this @chanon-onman please? Or maybe fix it? :) |
Have made #1102 to fix the code generator error |
Thank @Xtansia for your helps. Code:
Error:
|
@chanon-onman Yes the code generator is only recently introduced and have not yet started generating other operations yet. So there will be aspects of the more complicated operations such as search that's not yet implemented/handled by the generator. If you're interested in digging into this and working to get generation of search working, that'd be amazing, but unfortunately it's not going to be as simple as @dblock's comment might have suggested. The easier of the two options immediately would be to just amend the current SearchRequest implementation. |
@Xtansia Thanks for clarification. Can you help guide me how to modify SearchRequest deserializer? Does it need to use any code generator? |
Apologies for the delay @chanon-onman, I'm taking a look into this now |
Have found the issue (and made a fix in #1117), the actual typings in SearchRequest were correct (so generator wouldn't have changed anything), this was actually an issue in the general deserialization logic of how we handle "shortcut" properties on objects. ie. The real type is: {
"includes": ["_id"],
"excludes": []
} But we accept specifying just |
@chanon-onman The fix for this was just released as part of 2.13.0: https://central.sonatype.com/artifact/org.opensearch.client/opensearch-java/2.13.0 |
Thanks @Xtansia 👍 |
What is the bug?
The error
org.opensearch.client.json.UnexpectedJsonEventException: Unexpected JSON event 'START_ARRAY' instead of '[START_OBJECT, KEY_NAME, VALUE_STRING, VALUE_TRUE, VALUE_FALSE]
is raised when trying to deserialize following json payload toSearchRequest
.Context: We are implementing a kind of proxy service which accepts any OpenSearch requests and overwrite some query logic before passing them to the OpenSearch cluster. Previously, we use
opensearch-rest-high-level-client
withXContentParser
to parse incoming requests but now we would like to migrate toopensearch-java
library.Note that if
_source
is removed or change to string field, it can parse successfully but we cannot do this as a workaround as we expect to accept any form of valid requests from clients.How can one reproduce the bug?
Execute following code and then will get
org.opensearch.client.json.UnexpectedJsonEventException
What is the expected behavior?
We expect
SearchRequest._DESERIALIZER
can parse the json payload successfully.What is your host/environment?
The text was updated successfully, but these errors were encountered: