-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add per-index setting to limit number of nested fields #15989
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
Conversation
This looks good to me. One thing I'm wondering is whether we should only apply the limit to indices created on or after 2.3 in order to not fail recoveries of existing indices if they happen to cross the limit (unless maybe it's something that we want to do so that they know they are in a bad situation). cc @clintongormley |
@jpountz i agree that this should be for new indices (>= 2.3) |
Thinking a bit more about this, I noticed that the case where we update the new settings to a value lower than the current number of nested fields is not covered. After discussing with @jpountz and @s1monw, two possible ways to think about the nested fields limit came up:
or
In case we go with 2), I would drop the requirement that this only applies to new indices (>= 2.3). @jpountz @clintongormley thoughts? |
Good point - I think I prefer option 2 |
I think 2 is more practical too. |
755d20e
to
1ff8852
Compare
I agree that option 2 is better. Pushed a new set of changes, can you have a look again @jpountz ? Instead of adding an(other) ad-hoc parameter to merge, I created a MergeOptions class (maybe we should call it ValidationOptions?) Other options might be added there. In |
I am not sure I like giving an option to bypass this check. I would rather like to have a new enum parameter in the merge method that gives the context of the mapping update (type creation, mapping update or restoring an existing mapping) and apply the nested count check whenever it makes sense (type creation and mapping updates). I expect that it would also allow us to get rid of the |
If I'm not mistaken it would also work for the parent check which should only be applied for mapping updates. |
The reason I chose to set the options externally is that the options for such a context enum seem too complex to me. Looking at the current code on master, I identify 9 call sites:
I'm a bit hesitant on moving these case distinctions into MapperService. @jpountz how should we proceed? |
This would be useful in order to only perform some validations in the case of a mapping update and in cases when a mapping is restored eg. after a restart, such as discussed in elastic#15989. This replaces the current `applyDefault` parameter which can be derived from the mapping merge reason: the default mapping should be applied only in case of a mapping update, if the mapping does not exist yet and if this is not the default mapping.
1ff8852
to
a1b8dd2
Compare
LGTM |
This would be useful in order to only perform some validations in the case of a mapping update and in cases when a mapping is restored eg. after a restart, such as discussed in #15989. This replaces the current `applyDefault` parameter which can be derived from the mapping merge reason: the default mapping should be applied only in case of a mapping update, if the mapping does not exist yet and if this is not the default mapping.
Add per-index setting to limit number of nested fields
For the record, this setting was also made updatable via 6ca7909 |
Indexing a document with 100 nested fields actually indexes 101 documents as each nested
document is indexed as a separate document. To safeguard against ill-defined mappings
the number of nested fields that can be defined per index has been limited to 50. This
default limit can be changed with the index setting
index.mapping.nested_fields.limit
.Closes #14983