index-options.asciidoc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. [[index-options]]
  2. === `index_options`
  3. The `index_options` parameter controls what information is added to the
  4. inverted index for search and highlighting purposes. Only term-based field
  5. types like <<text,`text`>> and <<keyword,`keyword`>> support this
  6. configuration.
  7. The parameter accepts one of the following values. Each value retrieves
  8. information from the previous listed values. For example, `freqs` contains
  9. `docs`; `positions` contains both `freqs` and `docs`.
  10. `docs`::
  11. Only the doc number is indexed. Can answer the question _Does this term exist in
  12. this field?_
  13. `freqs`::
  14. Doc number and term frequencies are indexed. Term frequencies are used to score
  15. repeated terms higher than single terms.
  16. `positions` (default)::
  17. Doc number, term frequencies, and term positions (or order) are indexed.
  18. Positions can be used for <<query-dsl-match-query-phrase,proximity or phrase
  19. queries>>.
  20. `offsets`::
  21. Doc number, term frequencies, positions, and start and end character offsets
  22. (which map the term back to the original string) are indexed. Offsets are used
  23. by the <<unified-highlighter,unified highlighter>> to speed up highlighting.
  24. [source,console]
  25. --------------------------------------------------
  26. PUT my-index-000001
  27. {
  28. "mappings": {
  29. "properties": {
  30. "text": {
  31. "type": "text",
  32. "index_options": "offsets"
  33. }
  34. }
  35. }
  36. }
  37. PUT my-index-000001/_doc/1
  38. {
  39. "text": "Quick brown fox"
  40. }
  41. GET my-index-000001/_search
  42. {
  43. "query": {
  44. "match": {
  45. "text": "brown fox"
  46. }
  47. },
  48. "highlight": {
  49. "fields": {
  50. "text": {} <1>
  51. }
  52. }
  53. }
  54. --------------------------------------------------
  55. <1> The `text` field will use the postings for the highlighting by default because `offsets` are indexed.