Elasticsearch & Lucene (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is the difference between a Refresh and a Flush in Elasticsearch?
senior LevelCode ExampleelasticsearchAdvanced Internals
In Simple Words:
- Refresh (
refresh_interval, default 1s): Writes in-memory indexing buffers to a new Lucene segment in the OS file system cache. The document becomes searchable ("Near Real-Time" search), but is not yet fsynced to disk. - Flush: Executes a Lucene commit point. Fsyncs all OS cached segments to physical persistent disk and clears the Translog (Transaction Log). Happens every 30 minutes or when translog hits 512 MB.
text
Write Lifecycle:
Document -> In-Memory Buffer & Translog (WAL)
│
(Refresh: 1s)
▼
New Lucene Segment (Searchable in OS Cache)
│
(Flush: 30m / 512MB)
▼
Fsync to Persistent Disk & Truncate Translog