index-options.asciidoc 1.8 KB

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