1
0

index-options.asciidoc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 datatypes.
  9. ====
  10. It accepts the following values:
  11. `docs`::
  12. Only the doc number is indexed. Can answer the question _Does this term
  13. exist in this field?_
  14. `freqs`::
  15. Doc number and term frequencies are indexed. Term frequencies are used to
  16. score repeated terms higher than single terms.
  17. `positions` (default)::
  18. Doc number, term frequencies, and term positions (or order) are indexed.
  19. Positions can be used for
  20. <<query-dsl-match-query-phrase,proximity or phrase queries>>.
  21. `offsets`::
  22. Doc number, term frequencies, positions, and start and end character
  23. offsets (which map the term back to the original string) are indexed.
  24. Offsets are used by the <<unified-highlighter,unified highlighter>> to speed up highlighting.
  25. [source,console]
  26. --------------------------------------------------
  27. PUT my_index
  28. {
  29. "mappings": {
  30. "properties": {
  31. "text": {
  32. "type": "text",
  33. "index_options": "offsets"
  34. }
  35. }
  36. }
  37. }
  38. PUT my_index/_doc/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. <1> The `text` field will use the postings for the highlighting by default because `offsets` are indexed.