# _field_names field

原文链接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.3/mapping-field-names-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/mapping-field-names-field.html)

译文链接 : [http://www.apache.wiki/display/Elasticsearch/_field_names+field](http://www.apache.wiki/display/Elasticsearch/_field_names+field)

贡献者 : [朱彦安](/display/~zhuyanan)，[ApacheCN](/display/~apachecn)，[Apache中文网](/display/~apachechina)

该 **_field_names**字段索引包含除 **null **之外的任何值的文档中每个字段的名称。 该字段通过 **[exists](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-exists-query.html) **查询以查找特定字段具有或不具有任何非空值的文档。

该 **_field_names**字段的值可以在查询中被访问：

```
# 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
    }
  }
}
```

| 1 | 在 **_field_names** 字段上查询（参考 **[exists](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-exists-query.html)** 查询） |