> For the complete documentation index, see [llms.txt](https://xiaoxiami.gitbook.io/elasticsearch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xiaoxiami.gitbook.io/elasticsearch/ji-chu/33-apis/343sou-suo-apis-search-apis/field-capabilities-api.md).

# Field Capabilities API

> 5.3新增，这个功能是实验性的,可能在将来的版本完全被改变或删除。

字段折叠API允许检索字段在多个索引的功能。

字段折叠API默认执行在所有索引上:

```
GET _field_caps?fields=rating
```

1.请求也可以限制到特定的索引上:

```
GET twitter/_field_caps?fields=rating
```

或者字段选项也可以在请求体中定义:

```
POST _field_caps
{
   "fields" : ["rating"]
}
```

这种请求和之前的请求结果相同。

支持请求的选项：

| fields | 字段的列表计算统计数据。字段名支持通配符符号。例如,使用text\_ \*将导致所有字段匹配的表达式返回。 |
| ------ | ----------------------------------------------------- |

## Field Capabilities

Field Capabilities API 每个字段返回以下信息:

| searchable                 | Whether this field is indexed for search on all indices.                                                                 |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| aggregatable               | Whether this field can be aggregated on all indices.                                                                     |
| indices                    | The list of indices where this field has the same type, or null if all indices have the same type for the field.         |
| non\_searchable\_indices   | The list of indices where this field is not searchable, or null if all indices have the same definition for the field.   |
| non\_aggregatable\_indices | The list of indices where this field is not aggregatable, or null if all indices have the same definition for the field. |

## 响应格式：

请求：

```
GET _field_caps?fields=rating,title
```

```
{
    "fields": {
        "rating": {    # 1
            "long": {
                "searchable": true,
                "aggregatable": false,
                "indices": ["index1", "index2"],
                "non_aggregatable_indices": ["index1"]  # 2
            },
            "keyword": {
                "searchable": false,
                "aggregatable": true,
                "indices": ["index3", "index4"],
                "non_searchable_indices": ["index4"]  # 3
            }
        },
        "title": {  # 4
            "text": {
                "searchable": true,
                "aggregatable": false

            }
        }
    }
}
```

| [ ![](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/images/icons/callouts/1.png)](https://www.gitbook.com/book/xiaoxiami/elasticsearch/edit#)                               |                                                    | The field`rating`is defined as a long in`index1`and`index2`and as a`keyword`in`index3`and`index4`. |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/images/icons/callouts/2.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-field-caps.html#CO50-2) | The field`rating`is not aggregatable in`index1`.   |                                                                                                    |
| [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/images/icons/callouts/3.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-field-caps.html#CO50-3) | The field`rating`is not searchable in`index4`.     |                                                                                                    |
| [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/images/icons/callouts/4.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-field-caps.html#CO50-4) | The field`title`is defined as`text`in all indices. |                                                                                                    |
