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
143 lines
3.5 KiB
Text
143 lines
3.5 KiB
Text
[[indices-flush]]
|
|
=== Flush API
|
|
++++
|
|
<titleabbrev>Flush</titleabbrev>
|
|
++++
|
|
|
|
Flushes one or more data streams or indices.
|
|
|
|
[source,console]
|
|
--------------------------------------------------
|
|
POST /my-index-000001/_flush
|
|
--------------------------------------------------
|
|
// TEST[setup:my_index]
|
|
|
|
|
|
[[flush-api-request]]
|
|
==== {api-request-title}
|
|
|
|
`POST /<target>/_flush`
|
|
|
|
`GET /<target>/_flush`
|
|
|
|
`POST /_flush`
|
|
|
|
`GET /_flush`
|
|
|
|
[[flush-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.
|
|
|
|
[[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 in to 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. 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 aliases to
|
|
flush. Supports wildcards (`*`). To flush all data streams and indices, omit
|
|
this parameter or use `*` or `_all`.
|
|
|
|
[[flush-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`.
|
|
|
|
`force`::
|
|
+
|
|
--
|
|
(Optional, Boolean)
|
|
If `true`,
|
|
the request forces a flush
|
|
even if there are no changes to commit to the index.
|
|
Defaults to `false`.
|
|
|
|
You can use this parameter
|
|
to increment the generation number of the transaction log.
|
|
|
|
This parameter is considered internal.
|
|
--
|
|
|
|
|
|
include::{es-ref-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 /my-index-000001/_flush
|
|
----
|
|
// TEST[s/^/PUT my-index-000001\n/]
|
|
|
|
|
|
[[flush-multi-index]]
|
|
===== Flush several data streams and indices
|
|
|
|
[source,console]
|
|
----
|
|
POST /my-index-000001,my-index-000002/_flush
|
|
----
|
|
// TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/]
|
|
|
|
|
|
[[flush-api-all-ex]]
|
|
===== Flush all data streams and indices in a cluster
|
|
|
|
[source,console]
|
|
----
|
|
POST /_flush
|
|
----
|