index-options.asciidoc 1.6 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 <<postings-highlighter,postings highlighter>>.
  21. <<mapping-index,Analyzed>> string fields use `positions` as the default, and
  22. all other fields use `docs` as the default.
  23. [source,js]
  24. --------------------------------------------------
  25. PUT my_index
  26. {
  27. "mappings": {
  28. "my_type": {
  29. "properties": {
  30. "text": {
  31. "type": "text",
  32. "index_options": "offsets"
  33. }
  34. }
  35. }
  36. }
  37. }
  38. PUT my_index/my_type/1
  39. {
  40. "text": "Quick brown fox"
  41. }
  42. GET my_index/_search
  43. {
  44. "query": {
  45. "match": {
  46. "text": "brown fox"
  47. }
  48. },
  49. "highlight": {
  50. "fields": {
  51. "text": {} <1>
  52. }
  53. }
  54. }
  55. --------------------------------------------------
  56. // CONSOLE
  57. <1> The `text` field will use the postings highlighter by default because `offsets` are indexed.