[[indices-flush]] === Flush API ++++ Flush ++++ Flushes one or more indices. [source,console] -------------------------------------------------- POST /twitter/_flush -------------------------------------------------- // TEST[setup:twitter] [[flush-api-request]] ==== {api-request-title} `POST //_flush` `GET //_flush` `POST /_flush` `GET /_flush` [[flush-api-desc]] ==== {api-description-title} Flushing an index is the process of making sure that any data that is currently only stored in the <> 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 <>. 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} include::{docdir}/rest-api/common-parms.asciidoc[tag=index] + To flush all indices, omit this parameter or use a value of `_all` or `*`. [[flush-api-query-params]] ==== {api-query-parms-title} include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices] + Defaults to `true`. include::{docdir}/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::{docdir}/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 index [source,console] ---- POST /kimchy/_flush ---- // TEST[s/^/PUT kimchy\n/] [[flush-multi-index]] ===== Flush several indices [source,console] ---- POST /kimchy,elasticsearch/_flush ---- // TEST[s/^/PUT kimchy\nPUT elasticsearch\n/] [[flush-api-all-ex]] ===== Flush all indices [source,console] ---- POST /_flush ----