-->

Doc value Fields

Allows to return the doc value representation of a field for each hit, for example:

GET /_search
{
    "query" : {
        "match_all": {}
    },
    "docvalue_fields" : [
        "my_ip_field", 
        {
            "field": "my_keyword_field" 
        },
        {
            "field": "my_date_field",
            "format": "epoch_millis" 
        }
    ]
}

the name of the field

an object notation is supported as well

the object notation allows to specify a custom format

Doc value fields can work on fields that have doc-values enabled, regardless of whether they are stored

* can be used as a wild card, for example:

GET /_search
{
    "query" : {
        "match_all": {}
    },
    "docvalue_fields" : [
        {
            "field": "*_date_field", 
            "format": "epoch_millis" 
        }
    ]
}

Match all fields ending with field

Format to be applied to all matching fields.

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

While most fields do not support custom formats, some of them do:

By default fields are formatted based on a sensible configuration that depends 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.