IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Using the _size field
editUsing the _size
field
editIn order to enable the _size
field, set the mapping as follows:
PUT my-index-000001 { "mappings": { "_size": { "enabled": true } } }
The value of the _size
field is accessible in queries, aggregations, scripts,
and when sorting:
# Example documents PUT my-index-000001/_doc/1 { "text": "This is a document" } PUT my-index-000001/_doc/2 { "text": "This is another document" } GET my-index-000001/_search { "query": { "range": { "_size": { "gt": 10 } } }, "aggs": { "sizes": { "terms": { "field": "_size", "size": 10 } } }, "sort": [ { "_size": { "order": "desc" } } ], "script_fields": { "size": { "script": "doc['_size']" } }, "docvalue_fields": [ { "field": "_size" } ] }
Querying on the |
|
Aggregating on the |
|
Sorting on the |
|
Uses a
script field
to return the |
|
Uses a
doc value
field to return the |