Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
[[search-field-caps]]
|
2020-09-08 12:19:04 -04:00
|
|
|
=== Field capabilities API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Field capabilities</titleabbrev>
|
|
|
|
++++
|
|
|
|
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
Allows you to retrieve the capabilities of fields among multiple indices.
|
2020-07-09 16:54:33 -04:00
|
|
|
For data streams, the API returns field capabilities among the stream's backing
|
|
|
|
indices.
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
--------------------------------------------------
|
2019-09-20 05:24:44 -04:00
|
|
|
GET /_field_caps?fields=rating
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
[[search-field-caps-api-request]]
|
|
|
|
==== {api-request-title}
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2020-09-08 12:19:04 -04:00
|
|
|
`GET /_field_caps?fields=<fields>`
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2020-09-08 12:19:04 -04:00
|
|
|
`POST /_field_caps?fields=<fields>`
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2020-09-08 12:19:04 -04:00
|
|
|
`GET /<target>/_field_caps?fields=<fields>`
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2020-09-08 12:19:04 -04:00
|
|
|
`POST /<target>/_field_caps?fields=<fields>`
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
[[search-field-caps-api-desc]]
|
|
|
|
==== {api-description-title}
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
|
|
|
|
2020-06-18 04:23:26 -04:00
|
|
|
The field capabilities API returns the information about the capabilities of
|
2019-09-20 05:24:44 -04:00
|
|
|
fields among multiple indices.
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
[[search-field-caps-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
2020-07-09 16:54:33 -04:00
|
|
|
`<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 `*`.
|
2019-09-20 05:24:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[search-field-caps-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
2020-09-08 12:19:04 -04:00
|
|
|
`fields`::
|
|
|
|
(Required, string)
|
|
|
|
Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`)
|
|
|
|
expressions are supported.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-02-24 05:57:32 -05:00
|
|
|
+
|
|
|
|
Defaults to `true`.
|
2019-09-20 05:24:44 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2019-09-20 05:24:44 -04:00
|
|
|
+
|
|
|
|
--
|
|
|
|
Defaults to `open`.
|
|
|
|
--
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
2019-09-20 05:24:44 -04:00
|
|
|
|
|
|
|
`include_unmapped`::
|
2020-06-18 04:23:26 -04:00
|
|
|
(Optional, boolean) If `true`, unmapped fields are included in the response.
|
2019-09-20 05:24:44 -04:00
|
|
|
Defaults to `false`.
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2020-06-18 04:23:26 -04:00
|
|
|
[[search-field-caps-api-request-body]]
|
|
|
|
==== {api-request-body-title}
|
|
|
|
|
|
|
|
`index_filter`::
|
|
|
|
(Optional, <<query-dsl,query object>> Allows to filter indices if the provided
|
|
|
|
query rewrites to `match_none` on every shard.
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
[[search-field-caps-api-response-body]]
|
|
|
|
==== {api-response-body-title}
|
2020-06-18 04:23:26 -04:00
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
|
2020-06-24 07:32:14 -04:00
|
|
|
The types used in the response describe _families_ of field types.
|
2020-08-26 14:24:09 -04:00
|
|
|
Normally a type family is the same as the field type declared in the mapping,
|
2020-06-24 07:32:14 -04:00
|
|
|
but to simplify matters certain field types that behave identically are
|
2020-08-26 14:24:09 -04:00
|
|
|
described using a type family. For example, `keyword`, `constant_keyword` and `wildcard`
|
|
|
|
field types are all described as the `keyword` type family.
|
2020-06-24 07:32:14 -04:00
|
|
|
|
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
|
|
|
|
`searchable`::
|
|
|
|
Whether this field is indexed for search on all indices.
|
|
|
|
|
|
|
|
`aggregatable`::
|
|
|
|
Whether this field can be aggregated on all indices.
|
|
|
|
|
|
|
|
`indices`::
|
2020-08-26 14:24:09 -04:00
|
|
|
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.
|
2019-09-20 05:24:44 -04:00
|
|
|
|
|
|
|
`non_searchable_indices`::
|
2020-06-18 04:23:26 -04:00
|
|
|
The list of indices where this field is not searchable, or null if all indices
|
2019-09-20 05:24:44 -04:00
|
|
|
have the same definition for the field.
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
|
|
|
`non_aggregatable_indices`::
|
2020-06-18 04:23:26 -04:00
|
|
|
The list of indices where this field is not aggregatable, or null if all
|
2019-09-20 05:24:44 -04:00
|
|
|
indices have the same definition for the field.
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
Add per-field metadata. (#50333)
This PR adds per-field metadata that can be set in the mappings and is later
returned by the field capabilities API. This metadata is completely opaque to
Elasticsearch but may be used by tools that index data in Elasticsearch to
communicate metadata about fields with tools that then search this data. A
typical example that has been requested in the past is the ability to attach
a unit to a numeric field.
In order to not bloat the cluster state, Elasticsearch requires that this
metadata be small:
- keys can't be longer than 20 chars,
- values can only be numbers or strings of no more than 50 chars - no inner
arrays or objects,
- the metadata can't have more than 5 keys in total.
Given that metadata is opaque to Elasticsearch, field capabilities don't try to
do anything smart when merging metadata about multiple indices, the union of
all field metadatas is returned.
Here is how the meta might look like in mappings:
```json
{
"properties": {
"latency": {
"type": "long",
"meta": {
"unit": "ms"
}
}
}
}
```
And then in the field capabilities response:
```json
{
"latency": {
"long": {
"searchable": true,
"aggreggatable": true,
"meta": {
"unit": [ "ms" ]
}
}
}
}
```
When there are no conflicts, values are arrays of size 1, but when there are
conflicts, Elasticsearch includes all unique values in this array, without
giving ways to know which index has which metadata value:
```json
{
"latency": {
"long": {
"searchable": true,
"aggreggatable": true,
"meta": {
"unit": [ "ms", "ns" ]
}
}
}
}
```
Closes #33267
2020-01-08 10:21:18 -05:00
|
|
|
`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.
|
|
|
|
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
[[search-field-caps-api-example]]
|
|
|
|
==== {api-examples-title}
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
|
|
|
|
2020-07-09 16:54:33 -04:00
|
|
|
The request can be restricted to specific data streams and indices:
|
2019-09-20 05:24:44 -04:00
|
|
|
|
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
GET my-index-000001/_field_caps?fields=rating
|
2019-09-20 05:24:44 -04:00
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
// TEST[setup:my_index]
|
2019-09-20 05:24:44 -04:00
|
|
|
|
|
|
|
|
2020-06-18 04:23:26 -04:00
|
|
|
The next example API call requests information about the `rating` and the
|
2019-09-20 05:24:44 -04:00
|
|
|
`title` fields:
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET _field_caps?fields=rating,title
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
The API returns the following response:
|
|
|
|
|
|
|
|
[source,console-result]
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"indices": [ "index1", "index2", "index3", "index4", "index5" ],
|
|
|
|
"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
|
|
|
|
|
|
|
|
}
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2019-09-20 05:24:44 -04:00
|
|
|
// TESTRESPONSE[skip:historically skipped]
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
|
|
|
<1> The field `rating` is defined as a long in `index1` and `index2`
|
|
|
|
and as a `keyword` in `index3` and `index4`.
|
|
|
|
<2> The field `rating` is not aggregatable in `index1`.
|
|
|
|
<3> The field `rating` is not searchable in `index4`.
|
|
|
|
<4> The field `title` is defined as `text` in all indices.
|
|
|
|
|
|
|
|
|
2019-04-25 12:13:48 -04:00
|
|
|
By default unmapped fields are ignored. You can include them in the response by
|
|
|
|
adding a parameter called `include_unmapped` in the request:
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2019-04-25 12:13:48 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET _field_caps?fields=rating,title&include_unmapped
|
|
|
|
--------------------------------------------------
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2020-06-18 04:23:26 -04:00
|
|
|
In which case the response will contain an entry for each field that is present
|
2019-09-20 05:24:44 -04:00
|
|
|
in some indices but not all:
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2019-09-20 05:24:44 -04:00
|
|
|
[source,console-result]
|
2019-04-25 12:13:48 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"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": { <1>
|
|
|
|
"indices": [ "index5" ],
|
|
|
|
"searchable": false,
|
|
|
|
"aggregatable": false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"title": {
|
|
|
|
"text": {
|
|
|
|
"indices": [ "index1", "index2", "index3", "index4" ],
|
|
|
|
"searchable": true,
|
|
|
|
"aggregatable": false
|
|
|
|
},
|
|
|
|
"unmapped": { <2>
|
|
|
|
"indices": [ "index5" ],
|
|
|
|
"searchable": false,
|
|
|
|
"aggregatable": false
|
|
|
|
}
|
2019-04-25 12:13:48 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2019-04-25 12:13:48 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2019-09-20 05:24:44 -04:00
|
|
|
// TESTRESPONSE[skip:historically skipped]
|
Add FieldCapabilities (_field_caps) API (#23007)
This change introduces a new API called `_field_caps` that allows to retrieve the capabilities of specific fields.
Example:
````
GET t,s,v,w/_field_caps?fields=field1,field2
````
... returns:
````
{
"fields": {
"field1": {
"string": {
"searchable": true,
"aggregatable": true
}
},
"field2": {
"keyword": {
"searchable": false,
"aggregatable": true,
"non_searchable_indices": ["t"]
"indices": ["t", "s"]
},
"long": {
"searchable": true,
"aggregatable": false,
"non_aggregatable_indices": ["v"]
"indices": ["v", "w"]
}
}
}
}
````
In this example `field1` have the same type `text` across the requested indices `t`, `s`, `v`, `w`.
Conversely `field2` is defined with two conflicting types `keyword` and `long`.
Note that `_field_caps` does not treat this case as an error but rather return the list of unique types seen for this field.
2017-03-31 09:34:46 -04:00
|
|
|
|
2019-04-25 12:13:48 -04:00
|
|
|
<1> The `rating` field is unmapped` in `index5`.
|
|
|
|
<2> The `title` field is unmapped` in `index5`.
|
2020-06-18 04:23:26 -04:00
|
|
|
|
|
|
|
It is also possible to filter indices with a query:
|
|
|
|
|
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
POST my-index-*/_field_caps?fields=rating
|
2020-06-18 04:23:26 -04:00
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"index_filter": {
|
|
|
|
"range": {
|
|
|
|
"@timestamp": {
|
|
|
|
"gte": "2018"
|
|
|
|
}
|
2020-06-18 04:23:26 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2020-06-18 04:23:26 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
// TEST[setup:my_index]
|
2020-06-18 04:23:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
In which case indices that rewrite the provided filter to `match_none` on every shard
|
|
|
|
will be filtered from the response.
|
|
|
|
|
|
|
|
--
|
|
|
|
[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 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.
|
|
|
|
====
|
|
|
|
--
|