Indexing Mode
Edit pageIndexing mode defines what parts of a document are indexed and how. It is set
per field with the _index option and controls two independent dimensions:
- terms build the inverted index, so the field can be matched by full-text and term queries.
- values build document value slots, so the field can be used for sorting, ranges, faceting and aggregations.
Each of those can be indexed under the field’s own prefix (field, so it is searched by naming the field) and/or under a shared global prefix (so it is searched without naming any field).
Available values for the _index option are:
_index | Terms | Values |
|---|---|---|
none | - | - |
field_terms | field | - |
field_values | - | field |
field_all | field | field |
global_terms | global | - |
global_values | - | global |
global_all | global | global |
terms | field + global | - |
values | - | field + global |
all | field + global | field + global |
The default is field_all (both terms and values, under the field prefix).
Example
Section titled “Example”The code field below is indexed as field_values (values only), while label
keeps the default field_all:
PUT /test_index_mode/
{ "_schema": { "code": { "_type": "keyword", "_index": "field_values" }, "label": { "_type": "text" } }}PUT /test_index_mode/1
{ "code": "AB-123", "label": "quick brown fox"}Because label has terms, it matches a term query:
SEARCH /test_index_mode/
{ "_query": { "label": "brown" }}But code has only values (no terms), so the same shape of query matches
nothing, even though its value is stored for sorting and ranges:
SEARCH /test_index_mode/
{ "_query": { "code": "AB-123" }}