Class IndexSearcherWrapper


  • public class IndexSearcherWrapper
    extends java.lang.Object
    Extension point to add custom functionality at request time to the DirectoryReader and IndexSearcher managed by the IndexShard.
    • Method Summary

      Modifier and Type Method Description
      protected org.apache.lucene.index.DirectoryReader wrap​(org.apache.lucene.index.DirectoryReader reader)
      Wraps the given DirectoryReader.
      protected org.apache.lucene.search.IndexSearcher wrap​(org.apache.lucene.search.IndexSearcher searcher)  
      Engine.Searcher wrap​(Engine.Searcher engineSearcher)
      If there are configured IndexSearcherWrapper instances, the IndexSearcher of the provided engine searcher gets wrapped and a new Engine.Searcher instances is returned, otherwise the provided Engine.Searcher is returned.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IndexSearcherWrapper

        public IndexSearcherWrapper()
    • Method Detail

      • wrap

        protected org.apache.lucene.index.DirectoryReader wrap​(org.apache.lucene.index.DirectoryReader reader)
                                                        throws java.io.IOException
        Wraps the given DirectoryReader. The wrapped reader can filter out document just like delete documents etc. but must not change any term or document content.

        NOTE: The wrapper has a per-request lifecycle, must delegate IndexReader.getReaderCacheHelper(), LeafReader.getCoreCacheHelper() and must be an instance of FilterDirectoryReader that eventually exposes the original reader via FilterDirectoryReader.getDelegate(). The returned reader is closed once it goes out of scope.

        Parameters:
        reader - The provided directory reader to be wrapped to add custom functionality
        Returns:
        a new directory reader wrapping the provided directory reader or if no wrapping was performed the provided directory reader
        Throws:
        java.io.IOException
      • wrap

        protected org.apache.lucene.search.IndexSearcher wrap​(org.apache.lucene.search.IndexSearcher searcher)
                                                       throws java.io.IOException
        Parameters:
        searcher - The provided index searcher to be wrapped to add custom functionality
        Returns:
        a new index searcher wrapping the provided index searcher or if no wrapping was performed the provided index searcher
        Throws:
        java.io.IOException