Flush APIedit

Flushes one or more data streams or indices.

POST /my-index-000001/_flush

Requestedit

POST /<target>/_flush

GET /<target>/_flush

POST /_flush

GET /_flush

Descriptionedit

Flushing a data stream or index is the process of making sure that any data that is currently only stored in the transaction log is also permanently stored in the Lucene index. When restarting, Elasticsearch 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. Elasticsearch 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 it is retained for some other reason. The transaction log is made up of multiple files, called generations, and Elasticsearch 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 Elasticsearch has flushed all the documents that were indexed before the flush API was called.

Path parametersedit

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

Query parametersedit

allow_no_indices

(Optional, Boolean) If false, the request returns an error when a wildcard expression, index alias, or _all value targets only missing or closed indices.

Defaults to true.

expand_wildcards

(Optional, string) Controls what kind of indices that wildcard expressions can expand to. Multiple values are accepted when separated by a comma, as in open,hidden. Valid values are:

all
Expand to open and closed indices, including hidden indices.
open
Expand only to open indices.
closed
Expand only to closed indices.
hidden
Expansion of wildcards will include hidden indices. Must be combined with open, closed, or both.
none
Wildcard expressions are not accepted.

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.

ignore_unavailable
(Optional, Boolean) If false, the request returns an error if it targets a missing or closed index. Defaults to false.
wait_if_ongoing

(Optional, Boolean) If true, the flush operation blocks until execution when another flush operation is running.

If false, Elasticsearch returns an error if you request a flush when another flush operation is running.

Defaults to true.

Examplesedit

Flush a specific data stream or indexedit

POST /my-index-000001/_flush

Flush several data streams and indicesedit

POST /my-index-000001,my-index-000002/_flush

Flush all data streams and indices in a clusteredit

POST /_flush