OpenSearch/docs/reference/indices/flush.asciidoc

143 lines
3.4 KiB
Plaintext

[[indices-flush]]
=== Flush API
++++
<titleabbrev>Flush</titleabbrev>
++++
Flushes one or more data streams or indices.
[source,console]
--------------------------------------------------
POST /twitter/_flush
--------------------------------------------------
// TEST[setup:twitter]
[[flush-api-request]]
==== {api-request-title}
`POST /<target>/_flush`
`GET /<target>/_flush`
`POST /_flush`
`GET /_flush`
[[flush-api-desc]]
==== {api-description-title}
Flushing a data stream or index is the process of making sure that any data that is currently
only stored in the <<index-modules-translog,transaction log>> is also
permanently stored in the Lucene index. When restarting, {es} replays any
unflushed operations from the transaction log into the Lucene index to bring it
back into the state that it was in before the restart. {es} automatically
triggers flushes as needed, using heuristics that trade off the size of the
unflushed transaction log against the cost of performing each flush.
Once each operation has been flushed it is permanently stored in the Lucene
index. This may mean that there is no need to maintain an additional copy of it
in the transaction log, unless <<index-modules-translog-retention,it is retained
for some other reason>>. The transaction log is made up of multiple files,
called _generations_, and {es} will delete any generation files once they are no
longer needed, freeing up disk space.
It is also possible to trigger a flush on one or more indices using the flush
API, although it is rare for users to need to call this API directly. If you
call the flush API after indexing some documents then a successful response
indicates that {es} has flushed all the documents that were indexed before the
flush API was called.
[[flush-api-path-params]]
==== {api-path-parms-title}
`<target>`::
(Optional, string)
Comma-separated list of data streams, indices, and index aliases to flush.
Wildcard expressions (`*`) are supported.
+
To flush all data streams and indices in a cluster, omit this parameter or use
`_all` or `*`.
[[flush-api-query-params]]
==== {api-query-parms-title}
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
+
Defaults to `true`.
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
+
Defaults to `open`.
`force`::
+
--
(Optional, boolean)
If `true`,
the request forces a flush
even if there are no changes to commit to the index.
Defaults to `true`.
You can use this parameter
to increment the generation number of the transaction log.
This parameter is considered internal.
--
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
`wait_if_ongoing`::
+
--
(Optional, boolean)
If `true`,
the flush operation blocks until execution
when another flush operation is running.
If `false`,
{es} returns an error
if you request a flush
when another flush operation is running.
Defaults to `true`.
--
[[flush-api-example]]
==== {api-examples-title}
[[flush-api-specific-ex]]
===== Flush a specific data stream or index
[source,console]
----
POST /kimchy/_flush
----
// TEST[s/^/PUT kimchy\n/]
[[flush-multi-index]]
===== Flush several data streams and indices
[source,console]
----
POST /kimchy,elasticsearch/_flush
----
// TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
[[flush-api-all-ex]]
===== Flush all data streams and indices in a cluster
[source,console]
----
POST /_flush
----