-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue #2759
Conversation
Signed-off-by: Bhavana Ramaram <[email protected]>
Have you checked any difference by wrapping index mapping with |
Signed-off-by: Bhavana Ramaram <[email protected]>
@rbhavna please unlink the opensearch bug as there are other impacted plugins that need to track it |
Yes when v1 template is added already, without _doc wrapper I see dynamic mappings are created. Will add details to PR description |
@ylwu-amzn I've tested all combinations (with and without _doc) and with/without v1 and v2 templates. The only failure occurs with the v1 template and lack of _doc. Adding _doc does not cause any additional problems and is, in fact, added by the REST API. @owaiskazi19 and I walked through all code paths with both deprecated v1 and current v2 mappings. In v2 case and with no v1 mapping, code automatically determines the _doc type at run time and thus these not impacted as they are processed in a list. The only impact is with v1 (deprecated) index templates which do a map "merge" and because the template populates the _doc field, it is now "present" and the auto-populating that occurs when there's no _doc doesn't happen and the user mapping is lost. |
@rbhavna just to be sure, can you also test with v2 templates both the scenario? |
@@ -87,7 +87,7 @@ public void initConversationMetaIndexIfAbsent(ActionListener<Boolean> listener) | |||
log.debug("No conversational meta index found. Adding it"); | |||
CreateIndexRequest request = Requests | |||
.createIndexRequest(META_INDEX_NAME) | |||
.mapping(ConversationalIndexConstants.META_MAPPING) | |||
.mapping("{\"_doc\":" + ConversationalIndexConstants.META_MAPPING + "}") |
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.
FYI after further research, another possible (and less controversial) fix is using a differnet method that includes the MediaType, which auto-adds the doc field internally. This format is also used elsewhere.
.mapping("{\"_doc\":" + ConversationalIndexConstants.META_MAPPING + "}") | |
.mapping(ConversationalIndexConstants.META_MAPPING, XContentType.JSON) |
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.
done
Thanks @owaiskazi19 Updated the description. And will do more testing with v2 templates |
I am actually curious if we can have similar fix for update index as well. This fix will take care of any newly created domains from 2.15. For domains upgrading from previous versions with incorrect mappings to 2.15, do you think adding this _doc wrapper helps? |
Signed-off-by: Bhavana Ramaram <[email protected]>
…to fix v1 templates issue (#2759) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5)
…to fix v1 templates issue (#2759) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5)
…to fix v1 templates issue (#2759) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5)
…to fix v1 templates issue (#2759) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5)
…to fix v1 templates issue (#2759) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5)
…to fix v1 templates issue (#2759) (#2766) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5) Co-authored-by: Bhavana Ramaram <[email protected]>
…to fix v1 templates issue (#2759) (#2763) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5) Co-authored-by: Bhavana Ramaram <[email protected]>
…to fix v1 templates issue (#2759) (#2764) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5) Co-authored-by: Bhavana Ramaram <[email protected]>
…to fix v1 templates issue (#2759) (#2765) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5) Co-authored-by: Bhavana Ramaram <[email protected]>
…to fix v1 templates issue (#2759) (#2767) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5) Co-authored-by: Bhavana Ramaram <[email protected]>
…to fix v1 templates issue (#2759) (#2766) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5) Co-authored-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 389dd95)
…to fix v1 templates issue (#2759) (#2766) (#3049) * Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 1c43be5) Co-authored-by: Bhavana Ramaram <[email protected]> (cherry picked from commit 389dd95) Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Description
Adds the _doc key wrapper around index mapping as required by CreateIndexRequest javadoc.
Related Issues
See also opensearch-project/OpenSearch#14984
Testing Details
When the cluster has v1 templates with patterns matching the index, without the _doc wrapper, dynamic mappings are getting enabled for the index. From below, created_time is being created as long (dynamically picked) instead of
timestamp
type which is defined in the mapping definition.With changes in this PR by adding
_doc
wrapper, even if cluster has v1 templates, indices are getting created with expected mappings.Check List
--signoff
.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.