doc-values.asciidoc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. [[doc-values]]
  2. === `doc_values`
  3. Most fields are <<mapping-index,indexed>> by default, which makes them
  4. searchable. The inverted index allows queries to look up the search term in
  5. unique sorted list of terms, and from that immediately have access to the list
  6. of documents that contain the term.
  7. Sorting, aggregations, and access to field values in scripts requires a
  8. different data access pattern. Instead of lookup up the term and finding
  9. documents, we need to be able to look up the document and find the terms that
  10. is has in a field.
  11. Doc values are the on-disk data structure, built at document index time, which
  12. makes this data access pattern possible. Doc values are supported on almost
  13. all field types, with the __notable exception of `analyzed` string fields__.
  14. All fields which support doc values have them enabled by default. If you are
  15. sure that you don't need to sort or aggregate on a field, or access the field
  16. value from a script, you can disable doc values in order to save disk space:
  17. [source,js]
  18. --------------------------------------------------
  19. PUT my_index
  20. {
  21. "mappings": {
  22. "my_type": {
  23. "properties": {
  24. "status_code": { <1>
  25. "type": "string",
  26. "index": "not_analyzed"
  27. },
  28. "session_id": { <2>
  29. "type": "string",
  30. "index": "not_analyzed",
  31. "doc_values": false
  32. }
  33. }
  34. }
  35. }
  36. }
  37. --------------------------------------------------
  38. // AUTOSENSE
  39. <1> The `status_code` field has `doc_values` enabled by default.
  40. <2> The `session_id` has `doc_values` disabled, but can still be queried.
  41. TIP: The `doc_values` setting is allowed to have different settings for fields
  42. of the same name in the same index. It can be disabled (set to `false`) on
  43. existing fields using the <<indices-put-mapping,PUT mapping API>>.