field-names-field.asciidoc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_names` 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)
  31. ==== Disabling `_field_names`
  32. Because `_field_names` introduce some index-time overhead, you might want to
  33. disable this field if you want to optimize for indexing speed and do not need
  34. `exists` queries.
  35. [source,js]
  36. --------------------------------------------------
  37. PUT tweets
  38. {
  39. "mappings": {
  40. "tweet": {
  41. "_field_names": {
  42. "enabled": false
  43. }
  44. }
  45. }
  46. }
  47. --------------------------------------------------
  48. // CONSOLE