Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/reference/search/run-a-search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,5 @@ GET /*/_search
====

include::request/from-size.asciidoc[]

include::search-fields.asciidoc[]
30 changes: 30 additions & 0 deletions docs/reference/search/search-fields.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[discrete]
[[search-fields]]
=== Return fields in a search

By default, each hit in the search response includes the document
<<mapping-source-field,`_source`>>, which is the entire JSON object that was
provided when indexing the document. Often only certain fields are required in
the response. In this case you can use
<<request-body-search-source-filtering,source filtering>> to restrict what
parts of the source are returned.

Returning fields using the document source has some limitations:

* The `_source` field does not include <<multi-fields, multi-fields>> or
<<alias, field aliases>>. Likewise, a field in the source will not contain
values that were copied into it through `copy_to`.
* Since the `_source` is stored as a single field in Lucene, the whole source
object must be loaded and parsed, even if only a small number of fields is needed.

Elasticsearch supports some alternative methods for returning fields that help
avoid these downsides:

* The <<request-body-search-docvalue-fields, docvalue fields>>
parameter allows for loading fields from their docvalues. This can be a good
choice when returning a fairly small number of fields that support docvalues,
such as keywords and dates.
* It's also possible to store an individual field's values by using the
<<mapping-store,`store`>> mapping option. These stored values can then be
returned in a search through the
<<request-body-search-stored-fields, `stored_fields`>> parameter.