index-options.asciidoc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. "properties": {
  30. "text": {
  31. "type": "text",
  32. "index_options": "offsets"
  33. }
  34. }
  35. }
  36. }
  37. PUT my_index/_doc/1
  38. {
  39. "text": "Quick brown fox"
  40. }
  41. GET my_index/_search
  42. {
  43. "query": {
  44. "match": {
  45. "text": "brown fox"
  46. }
  47. },
  48. "highlight": {
  49. "fields": {
  50. "text": {} <1>
  51. }
  52. }
  53. }
  54. --------------------------------------------------
  55. // CONSOLE
  56. <1> The `text` field will use the postings for the highlighting by default because `offsets` are indexed.