Field Capabilities API

edit

The field capabilities API allows to retrieve the capabilities of fields among multiple indices.

The field capabilities API by default executes on all indices:

GET _field_caps?fields=rating

The request can also be restricted to specific indices:

GET twitter/_field_caps?fields=rating

Supported request options:

fields

A list of fields to compute stats for. The field name supports wildcard notation. For example, using text_* will cause all fields that match the expression to be returned.

Field Capabilities

edit

The field capabilities API returns the following information per field:

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.

Response format

edit

Request:

GET _field_caps?fields=rating,title
{
    "indices": ["index1", "index2", "index3", "index4", "index5"],
    "fields": {
        "rating": { 
            "long": {
                "searchable": true,
                "aggregatable": false,
                "indices": ["index1", "index2"],
                "non_aggregatable_indices": ["index1"] 
            },
            "keyword": {
                "searchable": false,
                "aggregatable": true,
                "indices": ["index3", "index4"],
                "non_searchable_indices": ["index4"] 
            }
        },
        "title": { 
            "text": {
                "searchable": true,
                "aggregatable": false

            }
        }
    }
}

The field rating is defined as a long in index1 and index2 and as a keyword in index3 and index4.

The field rating is not aggregatable in index1.

The field rating is not searchable in index4.

The field title is defined as text in all indices.

Unmapped fields

edit

By default unmapped fields are ignored. You can include them in the response by adding a parameter called include_unmapped in the request:

GET _field_caps?fields=rating,title&include_unmapped

In which case the response will contain an entry for each field that is present in some indices but not all:

{
    "indices": ["index1", "index2", "index3"],
    "fields": {
        "rating": {
            "long": {
                "searchable": true,
                "aggregatable": false,
                "indices": ["index1", "index2"],
                "non_aggregatable_indices": ["index1"]
            },
            "keyword": {
                "searchable": false,
                "aggregatable": true,
                "indices": ["index3", "index4"],
                "non_searchable_indices": ["index4"]
            },
            "unmapped": { 
                "indices": ["index5"],
                "searchable": false,
                "aggregatable": false
            }
        },
        "title": {
            "text": {
                "indices": ["index1", "index2", "index3", "index4"],
                "searchable": true,
                "aggregatable": false
            },
            "unmapped": { 
                "indices": ["index5"]
                "searchable": false,
                "aggregatable": false
            }
        }
    }
}

The rating field is unmapped` in index5.

The title field is unmapped` in index5.