Flush a collection #
Queue a flush of every live shard copy of the collection, cluster-wide —
primaries and started replicas. A flush seals the shard’s mutable state
into the WAL and builds a new immutable .fire segment from the WAL tail,
turning in-memory writes into durable segment storage so the WAL can be
purged afterwards.
Unlike
Compact a collection — which merges existing segments
synchronously — a flush is asynchronous: each node holding copies of
the collection starts a node-local flush job and the request returns
immediately. Track or cancel the jobs on the node’s task list
(GET /_node/_local/tasks, flush_jobs lane). Only one flush job runs
per node at a time — a node already running one answers 409 in its row.
Examples #
The following request queues a forced flush of the collection called
my-collection:
POST /my-collection/_flush
The API returns the following result:
{
"collection": "default:my-collection",
"force": true,
"nodes": [
{
"node_id": "cc139a188e0642819003",
"job_id": "79982f4a058b4ef7b5cb",
"queued": 8
}
],
"queued": 8,
"failed": 0
}
To flush only what is currently due (respect the WAL and memtable
thresholds instead of forcing a seal), pass force=false:
POST /my-collection/_flush?force=false
Request #
POST /[<namespace>:]<name>/_flush
Path Parameters #
<namespace>
(Optional, string) The namespace which the collection belongs to.<name>
(Required, string) Name of the collection to flush.
Query Parameters #
force
(Optional, boolean, defaulttrue)trueseals the mutable state and builds a.firesegment even when no threshold is due — the operator asked for a flush now.falseflushes only shard copies with pending work. Also accepts0/no.
Response #
nodes— one row per node holding live copies of the collection:node_idplusjob_idandqueued(how many shard copies that node’s job covers) on success, or anerrorstring when the node did not answer or refused (already running a flush job).queued— the total number of shard-copy flushes queued across nodes.failed— how many node rows carry an error.
A collection with no started shard copies answers 409 — there is
nothing to flush.