Applications usually need only call the inherited {@link #search(Query,int)}or {@link #search(Query,Filter,int)} methods. Forperformance reasons, if your index is unchanging, you should share a single IndexSearcher instance across multiple searches instead of creating a new one per-search. If your index has changed and you wish to see the changes reflected in searching, you should use {@link IndexReader#openIfChanged} to obtain a new reader andthen create a new IndexSearcher from that. Also, for low-latency turnaround it's best to use a near-real-time reader ( {@link IndexReader#open(IndexWriter,boolean)}). Once you have a new {@link IndexReader}, it's relatively cheap to create a new IndexSearcher from it.
NOTE: {@link IndexSearcher}
instances are completely thread safe, meaning multiple threads can call any of its methods, concurrently. If your application requires external synchronization, you should not synchronize on the IndexSearcher
instance; use your own (non-Lucene) objects instead.
|
|
|
|