Skip to content
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

Merged
merged 6 commits into from
Nov 24, 2024

Conversation

playLeo
Copy link
Contributor

@playLeo playLeo commented Nov 18, 2024

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.

dblock
dblock previously requested changes Nov 19, 2024
Copy link
Member

@dblock dblock left a 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) {
Copy link
Member

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?

Copy link
Contributor Author

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

playLeo pushed a commit to playLeo/opensearch-java that referenced this pull request Nov 19, 2024
@playLeo playLeo force-pushed the fix/toJsonStringMapper branch 2 times, most recently from 99b5a6b to ee4d373 Compare November 19, 2024 16:55
reta
reta previously approved these changes Nov 23, 2024
Copy link
Collaborator

@reta reta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @playLeo !

@Xtansia Xtansia dismissed dblock’s stale review November 24, 2024 22:07

Requested changes have been made

@Xtansia Xtansia merged commit ca3d488 into opensearch-project:main Nov 24, 2024
55 of 56 checks passed
@Xtansia Xtansia added the backport 2.x Backport to 2.x branch label Nov 24, 2024
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

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 base branch is 2.x and the compare/head branch is backport/backport-1309-to-2.x.

@Xtansia
Copy link
Collaborator

Xtansia commented Nov 24, 2024

@playLeo Could you please manually backport this PR to 2.x following the above instructions?

playLeo added a commit to playLeo/opensearch-java that referenced this pull request Nov 25, 2024
* 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)
@playLeo
Copy link
Contributor Author

playLeo commented Nov 25, 2024

@Xtansia I've created a PR, and issue #1199 can also be closed

reta pushed a commit that referenced this pull request Nov 25, 2024
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants