Skip to content

Commit 4bd4eb1

Browse files
committed
Clarify the settings around limiting nested mappings. (#42686)
* 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.
1 parent 0469477 commit 4bd4eb1

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

docs/reference/mapping.asciidoc

+1-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ causing a mapping explosion:
8989
`2`, etc. The default is `20`.
9090

9191
`index.mapping.nested_fields.limit`::
92-
The maximum number of `nested` fields in an index, defaults to `50`.
93-
Indexing 1 document with 100 nested fields actually indexes 101 documents
94-
as each nested document is indexed as a separate hidden document.
95-
92+
The maximum number of distinct `nested` mappings in an index, defaults to `50`.
9693

9794
[float]
9895
== Dynamic mapping

docs/reference/mapping/types/nested.asciidoc

+16-6
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,20 @@ phase. Instead, highlighting needs to be performed via
195195
196196
=============================================
197197

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

201-
Indexing a document with 100 nested fields actually indexes 101 documents as each nested
202-
document is indexed as a separate document. To safeguard against ill-defined mappings
203-
the number of nested fields that can be defined per index has been limited to 50. See
204-
<<mapping-limit-settings>>.
201+
As described earlier, each nested object is indexed as a separate document under the hood.
202+
Continuing with the example above, if we indexed a single document containing 100 `user` objects,
203+
then 101 Lucene documents would be created -- one for the parent document, and one for each
204+
nested object. Because of the expense associated with `nested` mappings, Elasticsearch puts
205+
the following setting in place to guard against performance problems:
206+
207+
`index.mapping.nested_fields.limit`::
208+
209+
The `nested` type should only be used in special cases, when arrays of objects need to be
210+
queried independently of each other. To safeguard against poorly designed mappings, this setting
211+
limits the number of unique `nested` types per index. In our example, the `user` mapping would
212+
count as only 1 towards this limit. Defaults to 50.
213+
214+
Additional background on this setting can be found in <<mapping-limit-settings>>.

0 commit comments

Comments
 (0)