Skip to content

Indexing Mode

Edit page

Indexing 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:

_indexTermsValues
none--
field_termsfield-
field_values-field
field_allfieldfield
global_termsglobal-
global_values-global
global_allglobalglobal
termsfield + global-
values-field + global
allfield + globalfield + global

The default is field_all (both terms and values, under the field prefix).

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"
}
}