2013-08-28 19:24:34 -04:00
|
|
|
[[indices-clearcache]]
|
2019-10-01 17:07:28 -04:00
|
|
|
=== Clear cache API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Clear cache</titleabbrev>
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-10-07 09:36:30 -04:00
|
|
|
Clears caches for one or more indices.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-10-07 09:36:30 -04:00
|
|
|
----
|
2016-09-01 13:05:22 -04:00
|
|
|
POST /twitter/_cache/clear
|
2019-10-07 09:36:30 -04:00
|
|
|
----
|
2016-09-01 13:05:22 -04:00
|
|
|
// TEST[setup:twitter]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-10-07 09:36:30 -04:00
|
|
|
|
|
|
|
[[clear-cache-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
|
|
|
`POST /<index>/_cache/clear`
|
|
|
|
|
|
|
|
`POST /_cache/clear`
|
|
|
|
|
|
|
|
|
|
|
|
[[clear-cache-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
|
|
|
|
|
|
|
|
|
|
|
|
[[clear-cache-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-02-24 05:57:32 -05:00
|
|
|
+
|
|
|
|
Defaults to `true`.
|
2019-10-07 09:36:30 -04:00
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
|
|
|
+
|
|
|
|
Defaults to `open`.
|
|
|
|
|
|
|
|
`fielddata`::
|
|
|
|
+
|
|
|
|
--
|
|
|
|
(Optional, boolean)
|
|
|
|
If `true`,
|
|
|
|
clears the fields cache.
|
|
|
|
|
|
|
|
Use the `fields` parameter
|
|
|
|
to clear the cache of specific fields only.
|
|
|
|
--
|
|
|
|
|
|
|
|
`fields`::
|
|
|
|
+
|
|
|
|
--
|
|
|
|
(Optional, string)
|
|
|
|
Comma-separated list of field names
|
|
|
|
used to limit the `fielddata` parameter.
|
|
|
|
|
|
|
|
Defaults to all fields.
|
|
|
|
|
|
|
|
NOTE: This parameter does *not* support objects
|
|
|
|
or field aliases.
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
`index`::
|
|
|
|
(Optional, string)
|
|
|
|
Comma-separated list of index names
|
|
|
|
used to limit the request.
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
|
|
|
|
|
|
|
`query`::
|
|
|
|
(Optional, boolean)
|
|
|
|
If `true`,
|
|
|
|
clears the query cache.
|
|
|
|
|
|
|
|
`request`::
|
|
|
|
(Optional, boolean)
|
|
|
|
If `true`,
|
|
|
|
clears the request cache.
|
|
|
|
|
|
|
|
|
|
|
|
[[clear-cache-api-example]]
|
|
|
|
==== {api-examples-title}
|
|
|
|
|
|
|
|
|
|
|
|
[[clear-cache-api-specific-ex]]
|
|
|
|
===== Clear a specific cache
|
|
|
|
|
|
|
|
By default,
|
|
|
|
the clear cache API clears all caches.
|
|
|
|
You can clear only specific caches
|
|
|
|
by setting the following query parameters to `true`:
|
|
|
|
|
|
|
|
* `fielddata`
|
|
|
|
* `query`
|
|
|
|
* `request`
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-10-07 09:36:30 -04:00
|
|
|
----
|
|
|
|
POST /twitter/_cache/clear?fielddata=true <1>
|
|
|
|
POST /twitter/_cache/clear?query=true <2>
|
|
|
|
POST /twitter/_cache/clear?request=true <3>
|
|
|
|
----
|
2018-10-18 18:44:37 -04:00
|
|
|
// TEST[continued]
|
2019-09-06 11:31:13 -04:00
|
|
|
|
2019-10-07 09:36:30 -04:00
|
|
|
<1> Clears only the fields cache
|
|
|
|
<2> Clears only the query cache
|
|
|
|
<3> Clears only the request cache
|
2018-10-18 18:44:37 -04:00
|
|
|
|
2019-10-07 09:36:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[clear-cache-api-specific-fields-ex]]
|
|
|
|
===== Clear the cache of specific fields
|
|
|
|
|
|
|
|
To only clear the cache of specific fields,
|
|
|
|
use the `fields` query parameter.
|
2018-10-18 18:44:37 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-10-07 09:36:30 -04:00
|
|
|
----
|
2018-10-18 18:44:37 -04:00
|
|
|
POST /twitter/_cache/clear?fields=foo,bar <1>
|
2019-10-07 09:36:30 -04:00
|
|
|
----
|
2018-10-18 18:44:37 -04:00
|
|
|
// TEST[continued]
|
2019-09-06 11:31:13 -04:00
|
|
|
|
2019-10-07 09:36:30 -04:00
|
|
|
<1> Clear the cache for the `foo` and `bar` field
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
|
2019-10-07 09:36:30 -04:00
|
|
|
[[clear-cache-api-multi-ex]]
|
|
|
|
===== Clear caches for several indices
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-10-07 09:36:30 -04:00
|
|
|
----
|
2016-09-01 13:05:22 -04:00
|
|
|
POST /kimchy,elasticsearch/_cache/clear
|
2019-10-07 09:36:30 -04:00
|
|
|
----
|
|
|
|
// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-10-07 09:36:30 -04:00
|
|
|
|
|
|
|
[[clear-cache-api-all-ex]]
|
|
|
|
===== Clear caches for all indices
|
|
|
|
|
|
|
|
[source,console]
|
|
|
|
----
|
2016-09-01 13:05:22 -04:00
|
|
|
POST /_cache/clear
|
2019-10-07 09:36:30 -04:00
|
|
|
----
|