summaryrefslogtreecommitdiff
path: root/docs/reference/mapping/fields/field-names-field.asciidoc
blob: 45839ac55d95091a56aa04d03f97b78fa5b479fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
[[mapping-field-names-field]]
=== `_field_names` field

The `_field_names` field indexes the names of every field in a document that
contains any value other than `null`.  This field is used by the
<<query-dsl-exists-query,`exists`>> query to find documents that
either have or don't have any non-+null+ value for a particular field.

The value of the `_field_names` field is accessible in queries:

[source,js]
--------------------------
# Example documents
PUT my_index/my_type/1
{
  "title": "This is a document"
}

PUT my_index/my_type/2?refresh=true
{
  "title": "This is another document",
  "body": "This document has a body"
}

GET my_index/_search
{
  "query": {
    "terms": {
      "_field_names": [ "title" ] <1>
    }
  }
}

--------------------------
// CONSOLE

<1> Querying on the `_field_names` field (also see the <<query-dsl-exists-query,`exists`>> query)