Class SearcherFactory

  • public class SearcherFactory
    extends Object
    Factory class used by SearcherManager to create new IndexSearchers. The default implementation just creates an IndexSearcher with no custom behavior:
       public IndexSearcher newSearcher(IndexReader r) throws IOException {
         return new IndexSearcher(r);
    You can pass your own factory instead if you want custom behavior, such as:
    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Constructor Detail

      • SearcherFactory

        public SearcherFactory()
    • Method Detail

      • newSearcher

        public IndexSearcher newSearcher​(IndexReader reader,
                                         IndexReader previousReader)
                                  throws IOException
        Returns a new IndexSearcher over the given reader.
        reader - the reader to create a new searcher for
        previousReader - the reader previously used to create a new searcher. This can be null if unknown or if the given reader is the initially opened reader. If this reader is non-null it can be used to find newly opened segments compared to the new reader to warm the searcher up before returning.