2015-08-06 11:24:29 -04:00
|
|
|
[[index-options]]
|
|
|
|
=== `index_options`
|
|
|
|
|
|
|
|
The `index_options` parameter controls what information is added to the
|
2020-03-02 07:37:48 -05:00
|
|
|
inverted index for search and highlighting purposes.
|
2015-08-06 11:24:29 -04:00
|
|
|
|
2020-03-02 07:37:48 -05:00
|
|
|
[WARNING]
|
|
|
|
====
|
|
|
|
The `index_options` parameter is intended for use with <<text,`text`>> fields
|
|
|
|
only. Avoid using `index_options` with other field datatypes.
|
|
|
|
====
|
2015-08-06 11:24:29 -04:00
|
|
|
|
2020-03-02 07:37:48 -05:00
|
|
|
It accepts the following values:
|
2015-08-06 11:24:29 -04:00
|
|
|
|
2020-03-02 07:37:48 -05:00
|
|
|
`docs`::
|
|
|
|
Only the doc number is indexed. Can answer the question _Does this term
|
|
|
|
exist in this field?_
|
2015-08-06 11:24:29 -04:00
|
|
|
|
2020-03-02 07:37:48 -05:00
|
|
|
`freqs`::
|
|
|
|
Doc number and term frequencies are indexed. Term frequencies are used to
|
|
|
|
score repeated terms higher than single terms.
|
2015-08-06 11:24:29 -04:00
|
|
|
|
2020-03-02 07:37:48 -05:00
|
|
|
`positions` (default)::
|
|
|
|
Doc number, term frequencies, and term positions (or order) are indexed.
|
|
|
|
Positions can be used for
|
|
|
|
<<query-dsl-match-query-phrase,proximity or phrase queries>>.
|
2015-08-06 11:24:29 -04:00
|
|
|
|
|
|
|
`offsets`::
|
2020-03-02 07:37:48 -05:00
|
|
|
Doc number, term frequencies, positions, and start and end character
|
|
|
|
offsets (which map the term back to the original string) are indexed.
|
|
|
|
Offsets are used by the <<unified-highlighter,unified highlighter>> to speed up highlighting.
|
2015-08-06 11:24:29 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2015-08-06 11:24:29 -04:00
|
|
|
--------------------------------------------------
|
2019-01-22 09:13:52 -05:00
|
|
|
PUT my_index
|
2015-08-06 11:24:29 -04:00
|
|
|
{
|
|
|
|
"mappings": {
|
2019-01-22 09:13:52 -05:00
|
|
|
"properties": {
|
|
|
|
"text": {
|
|
|
|
"type": "text",
|
|
|
|
"index_options": "offsets"
|
2015-08-06 11:24:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-14 11:47:53 -05:00
|
|
|
PUT my_index/_doc/1
|
2015-08-06 11:24:29 -04:00
|
|
|
{
|
|
|
|
"text": "Quick brown fox"
|
|
|
|
}
|
|
|
|
|
|
|
|
GET my_index/_search
|
|
|
|
{
|
|
|
|
"query": {
|
|
|
|
"match": {
|
|
|
|
"text": "brown fox"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"highlight": {
|
|
|
|
"fields": {
|
|
|
|
"text": {} <1>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2019-09-06 11:31:13 -04:00
|
|
|
|
2017-06-09 08:09:57 -04:00
|
|
|
<1> The `text` field will use the postings for the highlighting by default because `offsets` are indexed.
|