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

            }
        }
    }
}

The fieldratingis defined as a long inindex1andindex2and as akeywordinindex3andindex4.

The fieldratingis not aggregatable inindex1.

The fieldratingis not searchable inindex4.

The fieldtitleis defined astextin all indices.

Last updated