-
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
Remove unsupported fields from PutMappingRequest #597
Conversation
Fixed the merge conflicts |
private final Boolean dateDetection; | ||
|
||
@Nullable | ||
private final DynamicMapping dynamic; |
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.
@VachaShah my apologies but I think we are removing the fields that are indeed supported and are valid, for example:
PutMappingRequest.Builder mappingsRequestBuilder = new PutMappingRequest.Builder().index("index")
.source(
new SourceField.Builder()
.enabled(true)
.build())
.routing(
new RoutingField.Builder()
.required(true)
.build())
.dynamic(DynamicMapping.Strict);
client.indices().putMapping(mappingsRequestBuilder.build());
Gives me perfectly updated index mappings:
{
"index" : {
"aliases" : { },
"mappings" : {
"dynamic" : "strict",
"_routing" : {
"required" : true
}
},
"settings" : {
"index" : {
"replication" : {
"type" : "DOCUMENT"
},
"number_of_shards" : "1",
"provided_name" : "index",
"creation_date" : "1692189016042",
"number_of_replicas" : "1",
"uuid" : "_5OAxCkmQZOzhWkEsyub3g",
"version" : {
"created" : "137217827"
}
}
}
}
}
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.
This is my bad! Thank you @reta for pointing out. Let me test this out and see if any other fields are supported as well. I will update the PR with the changes.
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.
@reta I tried all the fields and all fields work except runtime
. Sample code:
PutMappingRequest.Builder mappingsRequestBuilder = new PutMappingRequest.Builder().index("index")
.source(
new SourceField.Builder()
.enabled(true)
.build())
.routing(
new RoutingField.Builder()
.required(false)
.build())
.dynamic(DynamicMapping.Strict)
.meta("key", JsonData.of("key value"))
.fieldNames(new FieldNamesField.Builder().enabled(false).build())
.dateDetection(false)
.dynamicDateFormats(new ArrayList<>())
.dynamicTemplates(new ArrayList<>())
.numericDetection(false)
.runtime("runtime", new RuntimeField.Builder().type(RuntimeFieldType.Boolean).build());
client.indices().putMapping(mappingsRequestBuilder.build());
To which I got the below error:
Mapping response: org.opensearch.client.opensearch.indices.get_mapping.IndexMappingRecord@44040454
Exception in thread "main" org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [mapper_parsing_exception] Root mapping definition has unsupported parameters: [runtime : {runtime={type=boolean}}]
at org.opensearch.client.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:278)
at org.opensearch.client.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:144)
at org.opensearch.client.opensearch.indices.OpenSearchIndicesClient.putMapping(OpenSearchIndicesClient.java:1148)
at hello.OpenSearchValidateClient.main(OpenSearchValidateClient.java:234)
I think I am using runtime
parameter correctly but LMK if thats not the case.
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 @VachaShah !
I think I am using runtime parameter correctly but LMK if thats not the case.
Correct, we don't support runtime fields (this is ES only feature)
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.
Ah okay! I will update this PR accordingly. Thank you :)
Signed-off-by: Vacha Shah <[email protected]>
I think a good practice we could start following to catch bugs like the one @reta pointed out in the CR is to start adding working samples to https://github.com/opensearch-project/opensearch-java/tree/main/samples as part of these changes. Just an idea! |
Yup that makes sense! I have a working sample with which I tested. I will add it in an upcoming PR. |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-597-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d80f0151ca418d6a7bc63d2c616a88ba98d3c472
# Push it to GitHub
git push --set-upstream origin backport/backport-597-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x Then, create a pull request where the |
…project#597) Signed-off-by: Vacha Shah <[email protected]>
Signed-off-by: Vacha Shah <[email protected]>
Description
Finishing up PR #288
Issues Resolved
Closes #62
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.