Skip to content

Commit

Permalink
Clarify the settings around limiting nested mappings. (#42686)
Browse files Browse the repository at this point in the history
* Previously, we mentioned multiple times that each nested object was indexed as its own document. This is repetitive, and is also a bit confusing in the context of `index.mapping.nested_fields.limit`, as that applies to the number of distinct `nested` types in the mappings, not the number of nested objects. We now just describe the issue once at the beginning of the section, to illustrate why `nested` types can be expensive.
* Reference the ongoing example to clarify the meaning of the two settings.

Addresses #28363.
  • Loading branch information
jtibshirani committed May 30, 2019
1 parent 742697d commit e294bf5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
5 changes: 1 addition & 4 deletions docs/reference/mapping.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ causing a mapping explosion:
`2`, etc. The default is `20`.

`index.mapping.nested_fields.limit`::
The maximum number of `nested` fields in an index, defaults to `50`.
Indexing 1 document with 100 nested fields actually indexes 101 documents
as each nested document is indexed as a separate hidden document.

The maximum number of distinct `nested` mappings in an index, defaults to `50`.

[float]
== Dynamic mapping
Expand Down
22 changes: 16 additions & 6 deletions docs/reference/mapping/types/nested.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,20 @@ phase. Instead, highlighting needs to be performed via
=============================================

[[limit-number-nested-fields]]
==== Limiting the number of `nested` fields
[float]
=== Limits on `nested` mappings and objects

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. See
<<mapping-limit-settings>>.
As described earlier, each nested object is indexed as a separate document under the hood.
Continuing with the example above, if we indexed a single document containing 100 `user` objects,
then 101 Lucene documents would be created -- one for the parent document, and one for each
nested object. Because of the expense associated with `nested` mappings, Elasticsearch puts
the following setting in place to guard against performance problems:

`index.mapping.nested_fields.limit`::

The `nested` type should only be used in special cases, when arrays of objects need to be
queried independently of each other. To safeguard against poorly designed mappings, this setting
limits the number of unique `nested` types per index. In our example, the `user` mapping would
count as only 1 towards this limit. Defaults to 50.

Additional background on this setting can be found in <<mapping-limit-settings>>.

0 comments on commit e294bf5

Please sign in to comment.