Web / Apache Solr Interview questions
Why doesn't Solr return newly indexed documents without a commit?
This trips up a lot of developers new to Lucene-based search: calling add() does not make a document searchable, because Solr (via Lucene) uses snapshot isolation for reads.
Every search request runs against a specific IndexSearcher instance, which represents a fixed, immutable view of the index at the moment it was opened. Newly added documents sit in an in-memory buffer and the transaction log, invisible to any searcher opened before they arrived.
Only a commit - soft or hard - triggers Solr to open a new IndexSearcher that includes the latest changes, and swap it in for future requests. This design is deliberate: it keeps individual search requests fast and consistent, since a query doesn't have to worry about the index changing mid-execution, at the cost of writes not being instantly visible.
Applications that need documents to appear within milliseconds typically configure a short autoSoftCommit interval (for example, 1 second) rather than committing manually after every single write, which would be far too costly under load.
More Related questions...