[[mapper-size]] === Mapper Size Plugin The mapper-size plugin provides the `_size` metadata field which, when enabled, indexes the size in bytes of the original {ref}/mapping-source-field.html[`_source`] field. :plugin_name: mapper-size include::install_remove.asciidoc[] [[mapper-size-usage]] ==== Using the `_size` field In order to enable the `_size` field, set the mapping as follows: [source,console] -------------------------- PUT my-index-000001 { "mappings": { "_size": { "enabled": true } } } -------------------------- The value of the `_size` field is accessible in queries, aggregations, scripts, and when sorting: [source,console] -------------------------- # 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": { <1> "gt": 10 } } }, "aggs": { "sizes": { "terms": { "field": "_size", <2> "size": 10 } } }, "sort": [ { "_size": { <3> "order": "desc" } } ], "script_fields": { "size": { "script": "doc['_size']" <4> } }, "docvalue_fields": [ { "field": "_size" <5> } ] } -------------------------- // TEST[continued] <1> Querying on the `_size` field <2> Aggregating on the `_size` field <3> Sorting on the `_size` field <4> Uses a {ref}/search-fields.html#script-fields[script field] to return the `_size` field in the search response. <5> Uses a {ref}/search-fields.html#docvalue-fields[doc value field] to return the `_size` field in the search response. Doc value fields are useful if {ref}/modules-scripting-security.html#allowed-script-types-setting[inline scripts are disabled].