Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.4] [DOCS] Reformat clear cache API docs (#46512) #47663

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 121 additions & 36 deletions docs/reference/indices/clearcache.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,140 @@
<titleabbrev>Clear cache</titleabbrev>
++++

The clear cache API allows to clear either all caches or specific cached
associated with one or more indices.
Clears caches for one or more indices.

[source,js]
--------------------------------------------------
[source,console]
----
POST /twitter/_cache/clear
--------------------------------------------------
// CONSOLE
----
// TEST[setup:twitter]

The API, by default, will clear all caches. Specific caches can be cleaned
explicitly by setting the `query`, `fielddata` or `request` url parameter to `true`.

[source,js]
--------------------------------------------------
POST /twitter/_cache/clear?query=true <1>
POST /twitter/_cache/clear?request=true <2>
POST /twitter/_cache/clear?fielddata=true <3>
--------------------------------------------------
// CONSOLE
[[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]

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`

[source,console]
----
POST /twitter/_cache/clear?fielddata=true <1>
POST /twitter/_cache/clear?query=true <2>
POST /twitter/_cache/clear?request=true <3>
----
// TEST[continued]
<1> Cleans only the query cache
<2> Cleans only the request cache
<3> Cleans only the fielddata cache

In addition to this, all caches relating to a specific field can also be
cleared by specifying `fields` url parameter with a comma delimited list of
the fields that should be cleared. Note that the provided names must refer to
concrete fields -- objects and field aliases are not supported.
<1> Clears only the fields cache
<2> Clears only the query cache
<3> Clears only the request cache


[source,js]
--------------------------------------------------

[[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.

[source,console]
----
POST /twitter/_cache/clear?fields=foo,bar <1>
--------------------------------------------------
// CONSOLE
----
// TEST[continued]
<1> Clear the cache for the `foo` an `bar` field

[float]
==== Multi Index
<1> Clear the cache for the `foo` and `bar` field


The clear cache API can be applied to more than one index with a single
call, or even on `_all` the indices.
[[clear-cache-api-multi-ex]]
===== Clear caches for several indices

[source,js]
--------------------------------------------------
[source,console]
----
POST /kimchy,elasticsearch/_cache/clear
----
// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]


[[clear-cache-api-all-ex]]
===== Clear caches for all indices

[source,console]
----
POST /_cache/clear
--------------------------------------------------
// CONSOLE
// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
----