-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Flatten object mappings when subobjects is false #103542
Flatten object mappings when subobjects is false #103542
Conversation
Pinging @elastic/es-search (Team:Search) |
Hi @felixbarny, I've created a changelog YAML for you. |
c71feaf
to
47131c7
Compare
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
Hi @felixbarny, I've updated the changelog YAML for you. |
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 did a first pass and left a bunch of comments.
|
||
* The <<enabled, `enabled`>> mapping parameter must not be `false`. | ||
* The <<dynamic, `dynamic`>> mapping parameter must not contradict the implicit or explicit value of the parent. | ||
* The <<subobjects, `subobjects`>> mapping parameter mot not be set to `true` explicitly. |
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.
when can it happen that subobjects is re-enabled when it's been set to false for a certain branch in the object tree? I thought this is not allowed.
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.
Think of a component template (A) that was written with "traditional" object mappings in mind (subobjects is not set, the default value true is used). This PR makes it so that this component template can be used in combination with another component template (B) that sets subobjects to false. However, one limitation is that in component template A, the object mappers must not be defined with subobjects: true
. We could also choose to just discard the subobjects mapping parameter but I chose a more conservative approach that would reject such mappings. However, the consequence is that adding subobjects: false to existing mappings may 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.
ok. I see how this makes sense applied to component templates. I got confused because in the docs there is no context around component templates, and subobjects can't normally be changed back to true once set to false, so I was wondering: that is already not valid mappings, why do we need to state that explicitly. I am still uncertain of whether we should specify it or not.
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 realized this not only applies to component templates but also to mapping updates.
server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/Mapper.java
Outdated
Show resolved
Hide resolved
This is in preparation to make the field mutable, which is needed in the context of elastic#103542
This is in preparation to make the field mutable, which is needed in the context of #103542
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.
a few more questions and comments, this is almost ready.
server/src/main/java/org/elasticsearch/index/mapper/MapperMergeContext.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java
Outdated
Show resolved
Hide resolved
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.
LGTM, great work.
Closes #99860
Also fixes #103497