term-vector.asciidoc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. These term vectors can be stored so that they can be retrieved for a
  10. particular document.
  11. The `term_vector` setting accepts:
  12. [horizontal]
  13. `no`:: No term vectors are stored. (default)
  14. `yes`:: Just the terms in the field are stored.
  15. `with_positions`:: Terms and positions are stored.
  16. `with_offsets`:: Terms and character offsets are stored.
  17. `with_positions_offsets`:: Terms, positions, and character offsets are stored.
  18. The fast vector highlighter requires `with_positions_offsets`. The term
  19. vectors API can retrieve whatever is stored.
  20. WARNING: Setting `with_positions_offsets` will double the size of a field's
  21. index.
  22. [source,js]
  23. --------------------------------------------------
  24. PUT my_index
  25. {
  26. "mappings": {
  27. "properties": {
  28. "text": {
  29. "type": "text",
  30. "term_vector": "with_positions_offsets"
  31. }
  32. }
  33. }
  34. }
  35. PUT my_index/_doc/1
  36. {
  37. "text": "Quick brown fox"
  38. }
  39. GET my_index/_search
  40. {
  41. "query": {
  42. "match": {
  43. "text": "brown fox"
  44. }
  45. },
  46. "highlight": {
  47. "fields": {
  48. "text": {} <1>
  49. }
  50. }
  51. }
  52. --------------------------------------------------
  53. // CONSOLE
  54. <1> The fast vector highlighter will be used by default for the `text` field
  55. because term vectors are enabled.