index-options.asciidoc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. It accepts the
  5. following settings:
  6. [horizontal]
  7. `docs`::
  8. Only the doc number is indexed. Can answer the question _Does this term
  9. exist in this field?_
  10. `freqs`::
  11. Doc number and term frequencies are indexed. Term frequencies are used to
  12. score repeated terms higher than single terms.
  13. `positions`::
  14. Doc number, term frequencies, and term positions (or order) are indexed.
  15. Positions can be used for
  16. <<query-dsl-match-query-phrase,proximity or phrase queries>>.
  17. `offsets`::
  18. Doc number, term frequencies, positions, and start and end character
  19. offsets (which map the term back to the original string) are indexed.
  20. Offsets are used by the <<unified-highlighter,unified highlighter>> to speed up highlighting.
  21. NOTE: <<number,Numeric fields>> don't support the `index_options` parameter any longer.
  22. <<mapping-index,Analyzed>> string fields use `positions` as the default, and
  23. all other fields use `docs` as the default.
  24. [source,js]
  25. --------------------------------------------------
  26. PUT my_index
  27. {
  28. "mappings": {
  29. "_doc": {
  30. "properties": {
  31. "text": {
  32. "type": "text",
  33. "index_options": "offsets"
  34. }
  35. }
  36. }
  37. }
  38. }
  39. PUT my_index/_doc/1
  40. {
  41. "text": "Quick brown fox"
  42. }
  43. GET my_index/_search
  44. {
  45. "query": {
  46. "match": {
  47. "text": "brown fox"
  48. }
  49. },
  50. "highlight": {
  51. "fields": {
  52. "text": {} <1>
  53. }
  54. }
  55. }
  56. --------------------------------------------------
  57. // CONSOLE
  58. <1> The `text` field will use the postings for the highlighting by default because `offsets` are indexed.