Web / Apache Solr Interview questions
Explain the lifecycle of a document from indexing to searchability in Solr?
A document doesn't become searchable the instant it's added; it moves through several stages first.
- On
add, the document is first written to the transaction log (tlog) for crash recovery, and buffered in memory. - It is not yet searchable at this point - it exists in the buffer/tlog but not in any queryable Lucene segment.
- A soft commit opens a new searcher, making buffered changes visible to queries near-instantly, without necessarily flushing to disk.
- A hard commit (or a full RAM buffer) flushes data into an actual Lucene segment file on disk.
- Over time, small segments are combined by background merges to keep search performance from degrading as segment count grows.
This is why an application that adds a document and immediately searches for it - without waiting for at least a soft commit - can get a "not found" result even though the add call succeeded.
More Related questions...