mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 17:34:17 -04:00
* Remove `es-test-dir` book-scoped variable * Remove `plugins-examples-dir` book-scoped variable * Remove `:dependencies-dir:` and `:xes-repo-dir:` book-scoped variables - In `index.asciidoc`, two variables (`:dependencies-dir:` and `:xes-repo-dir:`) were removed. - In `sql/index.asciidoc`, the `:sql-tests:` path was updated to fuller path - In `esql/index.asciidoc`, the `:esql-tests:` path was updated idem * Replace `es-repo-dir` with `es-ref-dir` * Move `:include-xpack: true` to few files that use it, remove from index.asciidoc
115 lines
2.9 KiB
Text
115 lines
2.9 KiB
Text
[[indices-refresh]]
|
|
=== Refresh API
|
|
++++
|
|
<titleabbrev>Refresh</titleabbrev>
|
|
++++
|
|
|
|
A refresh makes recent operations performed on one or more indices available for
|
|
search. For data streams, the API runs the refresh operation on the stream's
|
|
backing indices. For more information about the refresh operation, see
|
|
<<near-real-time>>.
|
|
|
|
[source,console]
|
|
----
|
|
POST /my-index-000001/_refresh
|
|
----
|
|
// TEST[setup:my_index]
|
|
|
|
|
|
[[refresh-api-request]]
|
|
==== {api-request-title}
|
|
|
|
`POST <target>/_refresh`
|
|
|
|
`GET <target>/_refresh`
|
|
|
|
`POST /_refresh`
|
|
|
|
`GET /_refresh`
|
|
|
|
[[refresh-api-prereqs]]
|
|
==== {api-prereq-title}
|
|
|
|
* If the {es} {security-features} are enabled, you must have the `maintenance`
|
|
or `manage` <<privileges-list-indices,index privilege>> for the target data
|
|
stream, index, or alias.
|
|
|
|
[[refresh-api-desc]]
|
|
==== {api-description-title}
|
|
|
|
Use the refresh API to explicitly make all operations performed on one or more
|
|
indices since the last refresh available for search.
|
|
If the request targets a data stream, it refreshes the stream's backing indices.
|
|
|
|
// tag::refresh-interval-default[]
|
|
By default, Elasticsearch periodically refreshes indices every second, but only on
|
|
indices that have received one search request or more in the last 30 seconds.
|
|
// end::refresh-interval-default[]
|
|
You can change this default interval
|
|
using the <<index-refresh-interval-setting,`index.refresh_interval`>> setting.
|
|
|
|
Refresh requests are synchronous and do not return a response until the
|
|
refresh operation completes.
|
|
|
|
[IMPORTANT]
|
|
====
|
|
Refreshes are resource-intensive.
|
|
To ensure good cluster performance,
|
|
we recommend waiting for {es}'s periodic refresh
|
|
rather than performing an explicit refresh
|
|
when possible.
|
|
|
|
If your application workflow
|
|
indexes documents and then runs a search
|
|
to retrieve the indexed document,
|
|
we recommend using the <<docs-index_,index API>>'s
|
|
`refresh=wait_for` query parameter option.
|
|
This option ensures the indexing operation waits
|
|
for a periodic refresh
|
|
before running the search.
|
|
====
|
|
|
|
[[refresh-api-path-params]]
|
|
==== {api-path-parms-title}
|
|
|
|
`<target>`::
|
|
(Optional, string)
|
|
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`.
|
|
|
|
[[refresh-api-query-params]]
|
|
==== {api-query-parms-title}
|
|
|
|
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
|
+
|
|
Defaults to `true`.
|
|
|
|
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
|
+
|
|
Defaults to `open`.
|
|
|
|
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
|
|
|
|
|
[[refresh-api-example]]
|
|
==== {api-examples-title}
|
|
|
|
|
|
[[refresh-api-multiple-ex]]
|
|
===== Refresh several data streams and indices
|
|
|
|
[source,console]
|
|
----
|
|
POST /my-index-000001,my-index-000002/_refresh
|
|
----
|
|
// TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/]
|
|
|
|
|
|
[[refresh-api-all-ex]]
|
|
===== Refresh all data streams and indices in a cluster
|
|
|
|
[source,console]
|
|
----
|
|
POST /_refresh
|
|
----
|