field-names-field.asciidoc 873 B

12345678910111213141516171819202122232425262728293031323334353637
  1. [[mapping-field-names-field]]
  2. === `_field_names` field
  3. The `_field_names` field indexes the names of every field in a document that
  4. contains any value other than `null`. This field is used by the
  5. <<query-dsl-exists-query,`exists`>> query to find documents that
  6. either have or don't have any non-+null+ value for a particular field.
  7. The value of the `_field_name` field is accessible in queries:
  8. [source,js]
  9. --------------------------
  10. # Example documents
  11. PUT my_index/my_type/1
  12. {
  13. "title": "This is a document"
  14. }
  15. PUT my_index/my_type/2?refresh=true
  16. {
  17. "title": "This is another document",
  18. "body": "This document has a body"
  19. }
  20. GET my_index/_search
  21. {
  22. "query": {
  23. "terms": {
  24. "_field_names": [ "title" ] <1>
  25. }
  26. }
  27. }
  28. --------------------------
  29. // CONSOLE
  30. <1> Querying on the `_field_names` field (also see the <<query-dsl-exists-query,`exists`>> query)