NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Doc value Fields
editDoc value Fields
editAllows to return the doc value representation of a field for each hit, for example:
GET /_search { "query" : { "match_all": {} }, "docvalue_fields" : [ { "field": "my_ip_field", "format": "use_field_mapping" }, { "field": "my_date_field", "format": "epoch_millis" } ] }
the name of the field |
|
the special |
|
date fields may use a custom format |
Doc value fields can work on fields that are not stored.
*
can be used as a wild card, for example:
GET /_search { "query" : { "match_all": {} }, "docvalue_fields" : [ { "field": "*field", "format": "use_field_mapping" } ] }
Note that if the fields parameter specifies fields without docvalues it will try to load the value from the fielddata cache causing the terms for that field to be loaded to memory (cached), which will result in more memory consumption.
Custom formats
editWhile most fields do not support custom formats, some of them do:
- Date fields can take any date format.
- Numeric fields accept a DecimalFormat pattern.
All fields support the special use_field_mapping
format, which tells
Elasticsearch to use the mappings to figure out a default format.
The default is currently to return the same output as
script fields. However it will change in 7.0
to behave as if the use_field_mapping
format was provided.
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 inner_hits
block.