-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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] Type from nested fields using new metadata field mapper #3004
[Remove] Type from nested fields using new metadata field mapper #3004
Conversation
✅ Gradle Check success dd6b10427af69f2f02101fc5ca0b002f4253f3a4 |
server/src/main/java/org/opensearch/indices/mapper/MapperRegistry.java
Outdated
Show resolved
Hide resolved
public class NestedPathFieldMapper extends MetadataFieldMapper { | ||
// OpenSearch version 2.0 removed types; this name is used for bwc | ||
public static final String LEGACY_NAME = "_type"; | ||
public static final String NAME = "_nested_path"; |
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.
Just an opinion, _nested_path
looks too verbose, may be just _path
?
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 ended up sticking with _nested_path
because it's more descriptive when analyzing lucene segments (which has no object->field relationship). The fieldType is easily identifiable as the path for a nested field when just reading the field name.
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.nestedTypePathAsString = "__" + fullPath; | ||
this.nestedTypePathAsBytes = new BytesRef(nestedTypePathAsString); | ||
this.nestedTypeFilter = new TermQuery(new Term(TypeFieldMapper.NAME, nestedTypePathAsBytes)); | ||
Version version = Version.indexCreated(settings); |
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 a bit risky call: when fixing one of the Joda
conversions, realized that settings
may not hold the index created version all the time [1], may be worth checking here as well.
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.
Woah! Did you find this to be true in production or could it have just been a test that didn't set the Version? I don't think we can have a case where an index is created without a version, otherwise rolling upgrades would fail?
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.
It is this one https://github.com/opensearch-project/OpenSearch/pull/2094/files, to clarify, it is not caused by absence of the index created but prefabricated index settings which may not include it.
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.
Just getting back to this. The testDefaultConfig I had in there would've failed since it uses prefabricated empty settings but it was updating w/ different mappings so I added an explicit test based on #1921 to update with the same mappings and Empty settings. There are no issues; we may revisit if this rears it's head again.
server/src/main/java/org/opensearch/index/mapper/MapperService.java
Outdated
Show resolved
Hide resolved
Hey @nknize Just double checking -- I do not think you meant for this to get pulled into 2.0.0-rc1. If anything, we would fix it between 2.0.0-rc1 and 2.0.0, right? |
Correct. We just need to get it in for 2.0.0 along with TypeFieldMapper removal. |
75767ae
to
04319d2
Compare
✅ Gradle Check success 75767ae2fb4fcc747e871cdb83a67d57210cc8c9 |
✅ Gradle Check success 04319d2dad7d4bcbab3a1a16c3a654309d8f4b19 |
types support is removed yet nested documents use the _type field to store the path for nested documents. A new _nested_path metadata field mapper is added to take the place of the _type field in order to remove the type dependency in nested documents. BWC is handled in the new field mapper to ensure compatibility with older versions. Signed-off-by: Nicholas Walter Knize <[email protected]>
Signed-off-by: Nicholas Walter Knize <[email protected]>
Signed-off-by: Nicholas Walter Knize <[email protected]>
04319d2
to
bf6aecc
Compare
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.
Thank you @nknize for picking up this tricky change. LGTM!
I'm going to give this until COB today and will merge if there are no objections. We need to get this in. |
* [Remove] Type from nested fields using new metadata field mapper types support is removed yet nested documents use the _type field to store the path for nested documents. A new _nested_path metadata field mapper is added to take the place of the _type field in order to remove the type dependency in nested documents. BWC is handled in the new field mapper to ensure compatibility with older versions. Signed-off-by: Nicholas Walter Knize <[email protected]> * pr fixes Signed-off-by: Nicholas Walter Knize <[email protected]> * add test to merge same mapping with empty index settings Signed-off-by: Nicholas Walter Knize <[email protected]> (cherry picked from commit 6b641d2)
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.0 2.0
# Navigate to the new working tree
cd .worktrees/backport-2.0
# Create a new branch
git switch --create backport/backport-3004-to-2.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 6b641d2fd29b9542b94f419fc083847fa5bdf55b
# Push it to GitHub
git push --set-upstream origin backport/backport-3004-to-2.0
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.0 Then, create a pull request where the |
* [Remove] Type from nested fields using new metadata field mapper types support is removed yet nested documents use the _type field to store the path for nested documents. A new _nested_path metadata field mapper is added to take the place of the _type field in order to remove the type dependency in nested documents. BWC is handled in the new field mapper to ensure compatibility with older versions. Signed-off-by: Nicholas Walter Knize <[email protected]> (cherry picked from commit 6b641d2)
…nsearch-project#3004) * [Remove] Type from nested fields using new metadata field mapper types support is removed yet nested documents use the _type field to store the path for nested documents. A new _nested_path metadata field mapper is added to take the place of the _type field in order to remove the type dependency in nested documents. BWC is handled in the new field mapper to ensure compatibility with older versions. Signed-off-by: Nicholas Walter Knize <[email protected]>
…) (#3085) * [Remove] Type from nested fields using new metadata field mapper types support is removed yet nested documents use the _type field to store the path for nested documents. A new _nested_path metadata field mapper is added to take the place of the _type field in order to remove the type dependency in nested documents. BWC is handled in the new field mapper to ensure compatibility with older versions. Signed-off-by: Nicholas Walter Knize <[email protected]> (cherry picked from commit 6b641d2) Co-authored-by: Nick Knize <[email protected]>
…eld mapper (#3097) * [Remove] Type from nested fields using new metadata field mapper (#3004) * [Remove] Type from nested fields using new metadata field mapper types support is removed yet nested documents use the _type field to store the path for nested documents. A new _nested_path metadata field mapper is added to take the place of the _type field in order to remove the type dependency in nested documents. BWC is handled in the new field mapper to ensure compatibility with older versions. Signed-off-by: Nicholas Walter Knize <[email protected]> * spotless apply Signed-off-by: Nicholas Walter Knize <[email protected]> * add back Nested field mapper to IndicesModuleTests Signed-off-by: Nicholas Walter Knize <[email protected]>
types support is removed yet nested documents use the
_type
field to store thepath for nested documents. A new
_nested_path
metadata field mapper is added totake the place of the
_type
field in order to remove the type dependency innested documents. BWC is handled in the new field mapper to ensure compatibility
with older versions.
relates #1940
relates #2989