---
type: api
title: Get the field capabilities
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-field-caps
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-field-caps
products:
  - Elasticsearch Serverless
---

# Get the field capabilities


Availability:

## Paths

- `POST` (also `GET`) `/{index}/_field_caps`
- `POST` (also `GET`) `/_field_caps`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

- `index` (union IndexName | [] IndexName) — optional, leave it out to use `/_field_caps`
  A comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all.

## Description

Get information about the capabilities of fields among multiple indices.

For data streams, the API returns field capabilities among the stream’s backing indices.
It returns runtime fields like any other field.
For example, a runtime field with a type of keyword is returned the same as any other field that belongs to the `keyword` family.

## Required authorization

* Index privileges: `view_index_metadata`,`read`

## Query String Parameters

- `allow_no_indices` (boolean · default: true)
  A setting that does two separate checks on the index expression.
If `false`, the request returns an error (1) if any wildcard expression
(including `_all` and `*`) resolves to zero matching indices or (2) if the
complete set of resolved indices, aliases or data streams is empty after all
expressions are evaluated. If `true`, index expressions that resolve to no
indices are allowed and the request returns an empty result.
- `expand_wildcards` (string ExpandWildcards · default: open)
  The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`.

Supported values include:
  - `all`: Match any data stream or index, including hidden ones.
  - `open`: Match open, non-hidden indices. Also matches any non-hidden data stream.
  - `closed`: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.
  - `hidden`: Match hidden data streams and hidden indices. Must be combined with `open`, `closed`, or `both`.
  - `none`: Wildcard expressions are not accepted.
  Values: `all`, `open`, `closed`, `hidden`, `none`
- `fields` (union Fields)
  A comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.
  One of: `Field` or `Field[]`
- `ignore_unavailable` (boolean · default: false)
  If `false`, the request returns an error if it targets a concrete (non-wildcarded)
index, alias, or data stream that is missing, closed, or otherwise unavailable.
If `true`, unavailable concrete targets are silently ignored.
- `include_unmapped` (boolean · default: false)
  If true, unmapped fields are included in the response.
- `filters` (union string | [] string)
  A comma-separated list of filters to apply to the response.
  One of: `string` or `string[]`
- `types` ([] string)
  A comma-separated list of field types to include.
Any fields that do not match one of these types will be excluded from the results.
It defaults to empty, meaning that all field types are returned.
- `include_empty_fields` (boolean · default: true)
  If false, empty fields are not included in the response.

## Request Body

`application/json`

- `fields` (string Fields) — optional
  A list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.
- `index_filter` ({} QueryContainer) — optional
  Filter indices if the provided query rewrites to `match_none` on every shard.

IMPORTANT: The filtering is done on a best-effort basis, it uses index statistics and mappings to rewrite queries to `match_none` instead of fully running 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.
  See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/types/_types-query_dsl-querycontainer)
- `runtime_mappings` (RuntimeFields) — optional
  Define ad-hoc runtime fields in the request similar to the way it is done in search requests.
These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings.

## Response

`application/json`

- `indices` (string 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.
- `fields` (map string to string to FieldCapability)
## Code Examples

#### Console

```console
POST my-index-*/_field_caps?fields=rating
{
  "index_filter": {
    "range": {
      "@timestamp": {
        "gte": "2018"
      }
    }
  }
}
```

#### JavaScript

```javascript
const response = await client.fieldCaps({
  index: "my-index-*",
  fields: "rating",
  index_filter: {
    range: {
      "@timestamp": {
        gte: "2018",
      },
    },
  },
});
```

#### Python

```python
resp = client.field_caps(
    index="my-index-*",
    fields="rating",
    index_filter={
        "range": {
            "@timestamp": {
                "gte": "2018"
            }
        }
    },
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/my-index-*/_field_caps?fields=rating" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "index_filter": {
      "range": {
        "@timestamp": {
          "gte": "2018"
        }
      }
    }
  }'
```

#### Java

```java
client.fieldCaps(f -> f
    .fields("rating")
    .index("my-index-*")
    .indexFilter(i -> i
        .range(r -> r
            .untyped(u -> u
                .field("@timestamp")
                .gte(JsonData.fromJson("\"2018\""))
            )
        )
    )
);
```

#### C#

```c#
var response = await client
    .FieldCapsAsync(d1 => d1
        .Indices(new[] { "my-index-*" })
        .IndexFilter(d2 => d2
            .Range(new UntypedRangeQuery()
            {
                Field = global::Elastic.Clients.Elasticsearch.Infer.Field<MyDocument>(x => x.Timestamp),
                Gte = "2018"
            })
        )
    );
```

#### PHP

```php
$resp = $client->fieldCaps([
    "index" => "my-index-*",
    "fields" => "rating",
    "body" => [
        "index_filter" => [
            "range" => [
                "@timestamp" => [
                    "gte" => "2018",
                ],
            ],
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.field_caps(
  index: "my-index-*",
  fields: "rating",
  body: {
    "index_filter": {
      "range": {
        "@timestamp": {
          "gte": "2018"
        }
      }
    }
  }
)
```

## Response Examples

#### Get two fields

A successful response from `GET _field_caps?fields=rating,title`. 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. None of the fields are inference fields.

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

#### Get unmapped fields

A successful response from `GET _field_caps?fields=rating,title&include_unmapped`. The response contains an entry for each field that is present in some indices but not all. For example, the `rating` and `title` fields are unmapped in `index5`.

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

