docvalue-fields.asciidoc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. [[search-request-docvalue-fields]]
  2. === Doc value Fields
  3. Allows to return the <<doc-values,doc value>> representation of a field for each hit, for
  4. example:
  5. [source,js]
  6. --------------------------------------------------
  7. GET /_search
  8. {
  9. "query" : {
  10. "match_all": {}
  11. },
  12. "docvalue_fields" : [
  13. {
  14. "field": "my_ip_field", <1>
  15. "format": "use_field_mapping" <2>
  16. },
  17. {
  18. "field": "my_date_field",
  19. "format": "epoch_millis" <3>
  20. }
  21. ]
  22. }
  23. --------------------------------------------------
  24. // CONSOLE
  25. <1> the name of the field
  26. <2> the special `use_field_mapping` format tells Elasticsearch to use the format from the mapping
  27. <3> date fields may use a custom format
  28. Doc value fields can work on fields that are not stored.
  29. `*` can be used as a wild card, for example:
  30. [source,js]
  31. --------------------------------------------------
  32. GET /_search
  33. {
  34. "query" : {
  35. "match_all": {}
  36. },
  37. "docvalue_fields" : [
  38. {
  39. "field": "*field", <1>
  40. "format": "use_field_mapping" <2>
  41. }
  42. ]
  43. }
  44. --------------------------------------------------
  45. // CONSOLE
  46. <1> Match all fields ending with `field`
  47. <2> Format to be applied to all matching fields.
  48. Note that if the fields parameter specifies fields without docvalues it will try to load the value from the fielddata cache
  49. causing the terms for that field to be loaded to memory (cached), which will result in more memory consumption.
  50. [float]
  51. ==== Custom formats
  52. While most fields do not support custom formats, some of them do:
  53. - <<date,Date>> fields can take any <<mapping-date-format,date format>>.
  54. - <<number,Numeric>> fields accept a https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html[DecimalFormat pattern].
  55. All fields support the special `use_field_mapping` format, which tells
  56. Elasticsearch to use the mappings to figure out a default format.
  57. NOTE: The default is currently to return the same output as
  58. <<search-request-script-fields,script fields>>. However it will change in 7.0
  59. to behave as if the `use_field_mapping` format was provided.