Flush APIedit

Flushes one or more indices.

POST /twitter/_flush

Requestedit

POST /<index>/flush

GET /<index>/flush

POST /flush

GET /flush

Descriptionedit

Flushing an 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

<index>

(Optional, string) Comma-separated list or wildcard expression of index names used to limit the request.

To flush all indices, omit this parameter or use a value of _all or *.

Query parametersedit

allow_no_indices

(Optional, boolean) If true, the request does not return an error if a wildcard expression or _all value retrieves only missing or closed indices.

This parameter also applies to index aliases that point to a missing or closed index.

expand_wildcards

(Optional, string) Controls what kind of indices that wildcard expressions can expand to. Valid values are:

all
Expand to open and closed indices.
open
Expand only to open indices.
closed
Expand only to closed indices.
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 true, missing or closed indices are not included in the response. 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 indexedit

POST /kimchy/_flush

Flush several indicesedit

POST /kimchy,elasticsearch/_flush

Flush all indicesedit

POST /_flush