Field capabilities API

Allows you to retrieve the capabilities of fields among multiple indices. For data streams, the API returns field capabilities among the stream’s backing indices.

  1. GET /_field_caps?fields=rating

Request

GET /_field_caps?fields=<fields>

POST /_field_caps?fields=<fields>

GET /<target>/_field_caps?fields=<fields>

POST /<target>/_field_caps?fields=<fields>

Description

The field capabilities API returns the information about the capabilities of fields among multiple indices.

Path parameters

<target>

(Optional, string) Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are supported.

To target all data streams and indices in a cluster, omit this parameter or use _all or *.

Query parameters

fields

(Required, string) Comma-separated list of fields to retrieve capabilities for. Wildcard (*) expressions are supported.

allow_no_indices

(Optional, boolean) If true, the request does not return an error if a wildcard expression or _all value retrieves only missing or closed indices.

This parameter also applies to index aliases that point to a missing or closed index.

Defaults to true.

expand_wildcards

(Optional, string) Controls what kind of indices that wildcard expressions can expand to. Multiple values are accepted when separated by a comma, as in open,hidden. Valid values are:

  • all

    Expand to open and closed indices, including hidden indices.

    open

    Expand only to open indices.

    closed

    Expand only to closed indices.

    hidden

    Expansion of wildcards will include hidden indices. Must be combined with open, closed, or both.

    none

    Wildcard expressions are not accepted.

Defaults to open.

ignore_unavailable

(Optional, boolean) If true, missing or closed indices are not included in the response. Defaults to false.

include_unmapped

(Optional, boolean) If true, unmapped fields are included in the response. Defaults to false.

Request body

index_filter

(Optional, query object Allows to filter indices if the provided query rewrites to match_none on every shard.

Response body

The types used in the response describe families of field types. Normally a type family is the same as the field type declared in the mapping, but to simplify matters certain field types that behave identically are described using a type family. For example, keyword, constant_keyword and wildcard field types are all described as the keyword type family.

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 family, or null if all indices have the same type family 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.

meta

Merged metadata across all indices as a map of string keys to arrays of values. A value length of 1 indicates that all indices had the same value for this key, while a length of 2 or more indicates that not all indices had the same value for this key.

Examples

The request can be restricted to specific data streams and indices:

  1. GET my-index-000001/_field_caps?fields=rating

The next example API call requests information about the rating and the title fields:

  1. GET _field_caps?fields=rating,title

The API returns the following response:

  1. {
  2. "indices": [ "index1", "index2", "index3", "index4", "index5" ],
  3. "fields": {
  4. "rating": {
  5. "long": {
  6. "searchable": true,
  7. "aggregatable": false,
  8. "indices": [ "index1", "index2" ],
  9. "non_aggregatable_indices": [ "index1" ]
  10. },
  11. "keyword": {
  12. "searchable": false,
  13. "aggregatable": true,
  14. "indices": [ "index3", "index4" ],
  15. "non_searchable_indices": [ "index4" ]
  16. }
  17. },
  18. "title": {
  19. "text": {
  20. "searchable": true,
  21. "aggregatable": false
  22. }
  23. }
  24. }
  25. }

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.

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

  1. 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:

  1. {
  2. "indices": [ "index1", "index2", "index3" ],
  3. "fields": {
  4. "rating": {
  5. "long": {
  6. "searchable": true,
  7. "aggregatable": false,
  8. "indices": [ "index1", "index2" ],
  9. "non_aggregatable_indices": [ "index1" ]
  10. },
  11. "keyword": {
  12. "searchable": false,
  13. "aggregatable": true,
  14. "indices": [ "index3", "index4" ],
  15. "non_searchable_indices": [ "index4" ]
  16. },
  17. "unmapped": {
  18. "indices": [ "index5" ],
  19. "searchable": false,
  20. "aggregatable": false
  21. }
  22. },
  23. "title": {
  24. "text": {
  25. "indices": [ "index1", "index2", "index3", "index4" ],
  26. "searchable": true,
  27. "aggregatable": false
  28. },
  29. "unmapped": {
  30. "indices": [ "index5" ],
  31. "searchable": false,
  32. "aggregatable": false
  33. }
  34. }
  35. }
  36. }

The rating field is unmappedin <code>index5</code>.</p></td></tr><tr><td valign="top"><p><a href="#CO668-2"><i data-value="2"></i></a></p></td><td valign="top"><p>The <code>title</code> field is unmapped in index5.

It is also possible to filter indices with a query:

  1. POST my-index-*/_field_caps?fields=rating
  2. {
  3. "index_filter": {
  4. "range": {
  5. "@timestamp": {
  6. "gte": "2018"
  7. }
  8. }
  9. }
  10. }

In which case indices that rewrite the provided filter to match_none on every shard will be filtered from the response.

The filtering is done on a best-effort basis, it uses index statistics and mappings to rewrite queries to match_none instead of fully executing the request. For instance a range query over a date field can rewrite to match_none if all documents within a shard (including deleted documents) are outside of the provided range. However, not all queries can rewrite to match_none so this API may return an index even if the provided filter matches no document.