Get the field capabilities
Generally available
All methods and paths for this operation:
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
Path parameters
-
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.
Query parameters
-
If false, the request returns an error if any wildcard expression, index alias, or
_all
value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targetingfoo*,bar*
returns an error if an index starts with foo but no index starts with bar. -
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 withopen
,closed
, orboth
.none
: Wildcard expressions are not accepted.
Values are
all
,open
,closed
,hidden
, ornone
. -
A comma-separated list of fields to retrieve capabilities for. Wildcard (
*
) expressions are supported. -
If true, unmapped fields are included in the response.
-
A comma-separated list of filters to apply to the response.
-
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.
-
If false, empty fields are not included in the response.
Body
-
A list of fields to retrieve capabilities for. Wildcard (
*
) expressions are supported. -
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 tomatch_none
if all documents within a shard (including deleted documents) are outside of the provided range. However, not all queries can rewrite tomatch_none
so this API may return an index even if the provided filter matches no document.External documentation -
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.
POST my-index-*/_field_caps?fields=rating
{
"index_filter": {
"range": {
"@timestamp": {
"gte": "2018"
}
}
}
}
resp = client.field_caps(
index="my-index-*",
fields="rating",
index_filter={
"range": {
"@timestamp": {
"gte": "2018"
}
}
},
)
const response = await client.fieldCaps({
index: "my-index-*",
fields: "rating",
index_filter: {
range: {
"@timestamp": {
gte: "2018",
},
},
},
});
response = client.field_caps(
index: "my-index-*",
fields: "rating",
body: {
"index_filter": {
"range": {
"@timestamp": {
"gte": "2018"
}
}
}
}
)
$resp = $client->fieldCaps([
"index" => "my-index-*",
"fields" => "rating",
"body" => [
"index_filter" => [
"range" => [
"@timestamp" => [
"gte" => "2018",
],
],
],
],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"index_filter":{"range":{"@timestamp":{"gte":"2018"}}}}' "$ELASTICSEARCH_URL/my-index-*/_field_caps?fields=rating"
{
"index_filter": {
"range": {
"@timestamp": {
"gte": "2018"
}
}
}
}
{
"indices": [ "index1", "index2", "index3", "index4", "index5" ],
"fields": {
"rating": {
"long": {
"metadata_field": false,
"searchable": true,
"aggregatable": false,
"indices": [ "index1", "index2" ],
"non_aggregatable_indices": [ "index1" ]
},
"keyword": {
"metadata_field": false,
"searchable": false,
"aggregatable": true,
"indices": [ "index3", "index4" ],
"non_searchable_indices": [ "index4" ]
}
},
"title": {
"text": {
"metadata_field": false,
"searchable": true,
"aggregatable": false
}
}
}
}
{
"indices": [ "index1", "index2", "index3", "index4", "index5" ],
"fields": {
"rating": {
"long": {
"metadata_field": false,
"searchable": true,
"aggregatable": false,
"indices": [ "index1", "index2" ],
"non_aggregatable_indices": [ "index1" ]
},
"keyword": {
"metadata_field": false,
"searchable": false,
"aggregatable": true,
"indices": [ "index3", "index4" ],
"non_searchable_indices": [ "index4" ]
}
},
"title": {
"text": {
"metadata_field": false,
"searchable": true,
"aggregatable": false
}
}
}
}