term-vector.asciidoc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. [[term-vector]]
  2. === `term_vector`
  3. Term vectors contain information about the terms produced by the
  4. <<analysis,analysis>> process, including:
  5. * a list of terms.
  6. * the position (or order) of each term.
  7. * the start and end character offsets mapping the term to its
  8. origin in the original string.
  9. * payloads (if they are available) — user-defined binary data
  10. associated with each term position.
  11. These term vectors can be stored so that they can be retrieved for a
  12. particular document.
  13. The `term_vector` setting accepts:
  14. [horizontal]
  15. `no`:: No term vectors are stored. (default)
  16. `yes`:: Just the terms in the field are stored.
  17. `with_positions`:: Terms and positions are stored.
  18. `with_offsets`:: Terms and character offsets are stored.
  19. `with_positions_offsets`:: Terms, positions, and character offsets are stored.
  20. `with_positions_payloads`:: Terms, positions, and payloads are stored.
  21. `with_positions_offsets_payloads`:: Terms, positions, offsets and payloads are stored.
  22. The fast vector highlighter requires `with_positions_offsets`.
  23. <<docs-termvectors, The term vectors API>> can retrieve whatever is stored.
  24. WARNING: Setting `with_positions_offsets` will double the size of a field's
  25. index.
  26. [source,console]
  27. --------------------------------------------------
  28. PUT my-index-000001
  29. {
  30. "mappings": {
  31. "properties": {
  32. "text": {
  33. "type": "text",
  34. "term_vector": "with_positions_offsets"
  35. }
  36. }
  37. }
  38. }
  39. PUT my-index-000001/_doc/1
  40. {
  41. "text": "Quick brown fox"
  42. }
  43. GET my-index-000001/_search
  44. {
  45. "query": {
  46. "match": {
  47. "text": "brown fox"
  48. }
  49. },
  50. "highlight": {
  51. "fields": {
  52. "text": {} <1>
  53. }
  54. }
  55. }
  56. --------------------------------------------------
  57. <1> The fast vector highlighter will be used by default for the `text` field
  58. because term vectors are enabled.