Web / Apache Lucene Interview questions
What is the purpose of the IndexSearcher class?
IndexSearcher is the entry point for running queries against an index. It wraps an IndexReader, which provides a consistent, read-only snapshot of the index at a point in time.
Given a Query object, IndexSearcher builds a Weight and Scorer per segment, collects matching documents, ranks them using the configured Similarity, and returns a TopDocs object containing document IDs and scores. It also exposes helper methods like doc() to fetch stored fields for a matching document.
Because the underlying IndexReader is a fixed snapshot, an IndexSearcher won't see documents added after it was opened - applications refresh or reopen it periodically to pick up new content.
More Related questions...