-
Notifications
You must be signed in to change notification settings - Fork 190
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
Fix toJsonString default mapper serialize type #1309
Fix toJsonString default mapper serialize type #1309
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fix CI, add to CHANGELOG?
@@ -81,15 +81,30 @@ public <T> void serialize(T value, JsonGenerator generator) { | |||
return; | |||
} | |||
|
|||
if (value instanceof String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some else
here is better and avoids the early return
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, I'll apply it when I refactoring
java-client/src/main/java/org/opensearch/client/json/JsonpUtils.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Leo <[email protected]>
99b5a6b
to
ee4d373
Compare
Signed-off-by: Leo <[email protected]>
Signed-off-by: Leo <[email protected]>
…y JsonData raw value Signed-off-by: Leo <[email protected]>
Signed-off-by: Leo <[email protected]>
Signed-off-by: Leo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @playLeo !
Signed-off-by: Thomas Farr <[email protected]>
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/opensearch-java/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/opensearch-java/backport-2.x
# Create a new branch
git switch --create backport/backport-1309-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ca3d488366e72f6d6dce33266c88a6841996332f
# Push it to GitHub
git push --set-upstream origin backport/backport-1309-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/opensearch-java/backport-2.x Then, create a pull request where the |
@playLeo Could you please manually backport this PR to |
* fix toJsonString default mapper serialize type Signed-off-by: Leo <[email protected]> * test range query JsonData type value Signed-off-by: Leo <[email protected]> * refactor don't invoke the mapper's serialize method for the RangeQuery JsonData raw value Signed-off-by: Leo <[email protected]> * update CHANGELOG opensearch-project#1309 PR Signed-off-by: Leo <[email protected]> * add JsonDataImpl serialize value type Signed-off-by: Leo <[email protected]> --------- Signed-off-by: Leo <[email protected]> Signed-off-by: Thomas Farr <[email protected]> Co-authored-by: Leo <[email protected]> Co-authored-by: Thomas Farr <[email protected]> (cherry picked from commit ca3d488)
* fix toJsonString default mapper serialize type Signed-off-by: Leo <[email protected]> * test range query JsonData type value Signed-off-by: Leo <[email protected]> * refactor don't invoke the mapper's serialize method for the RangeQuery JsonData raw value Signed-off-by: Leo <[email protected]> * update CHANGELOG #1309 PR Signed-off-by: Leo <[email protected]> * add JsonDataImpl serialize value type Signed-off-by: Leo <[email protected]> --------- Signed-off-by: Leo <[email protected]> Signed-off-by: Thomas Farr <[email protected]> Co-authored-by: Leo <[email protected]> Co-authored-by: Thomas Farr <[email protected]> (cherry picked from commit ca3d488)
Description
The toJsonString method of SearchRequest uses the default mapper provided by JsonpUtils.
This mapper only supports serializing instances of the JsonpSerializable type.
Using JsonData values in a range query cannot be serialized.
To resolve this, add support for serializing Integer, Double, and String types in the default mapper of JsonpUtils.
Issues Resolved
This PR is related to #1171
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.