Skip to content

Commit

Permalink
Clarify that inner_hits must be used to access nested fields. (#42724)
Browse files Browse the repository at this point in the history
This PR updates the docs for `docvalue_fields` and `stored_fields` to clarify
that nested fields must be accessed through `inner_hits`. It also tweaks the
nested fields documentation to make this point more visible.

Addresses #23766.
  • Loading branch information
jtibshirani committed May 31, 2019
1 parent 7210020 commit b555f2b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
31 changes: 16 additions & 15 deletions docs/reference/mapping/types/nested.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ Nested documents can be:
* sorted with <<nested-sorting,nested sorting>>.
* retrieved and highlighted with <<nested-inner-hits,nested inner hits>>.

[IMPORTANT]
=============================================
Because nested documents are indexed as separate documents, they can only be
accessed within the scope of the `nested` query, the
`nested`/`reverse_nested` aggregations, or <<nested-inner-hits,nested inner hits>>.
For instance, if a string field within a nested document has
<<index-options,`index_options`>> set to `offsets` to allow use of the postings
during the highlighting, these offsets will not be available during the main highlighting
phase. Instead, highlighting needs to be performed via
<<nested-inner-hits,nested inner hits>>. The same consideration applies when loading
fields during a search through <<search-request-docvalue-fields, `docvalue_fields`>>
or <<search-request-stored-fields, `stored_fields`>>.
=============================================

[[nested-params]]
==== Parameters for `nested` fields
Expand All @@ -178,21 +194,6 @@ The following parameters are accepted by `nested` fields:
may be added to an existing nested object.


[IMPORTANT]
=============================================
Because nested documents are indexed as separate documents, they can only be
accessed within the scope of the `nested` query, the
`nested`/`reverse_nested` aggregations, or <<nested-inner-hits,nested inner hits>>.
For instance, if a string field within a nested document has
<<index-options,`index_options`>> set to `offsets` to allow use of the postings
during the highlighting, these offsets will not be available during the main highlighting
phase. Instead, highlighting needs to be performed via
<<nested-inner-hits,nested inner hits>>.
=============================================

[float]
=== Limits on `nested` mappings and objects

Expand Down
4 changes: 4 additions & 0 deletions docs/reference/search/request/docvalue-fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ on their mappings: `long`, `double` and other numeric fields are formatted as
numbers, `keyword` fields are formatted as strings, `date` fields are formatted
with the configured `date` format, etc.

NOTE: On its own, `docvalue_fields` cannot be used to load fields in nested
objects -- if a field contains a nested object in its path, then no data will
be returned for that docvalue field. To access nested fields, `docvalue_fields`
must be used within an <<search-request-inner-hits, `inner_hits`>> block.
5 changes: 5 additions & 0 deletions docs/reference/search/request/stored-fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ Script fields can also be automatically detected and used as fields, so
things like `_source.obj1.field1` can be used, though not recommended, as
`obj1.field1` will work as well.

NOTE: On its own, `stored_fields` cannot be used to load fields in nested
objects -- if a field contains a nested object in its path, then no data will
be returned for that stored field. To access nested fields, `stored_fields`
must be used within an <<search-request-inner-hits, `inner_hits`>> block.

==== Disable stored fields entirely

To disable the stored fields (and metadata fields) entirely use: `_none_`:
Expand Down

0 comments on commit b555f2b

Please sign in to comment.