Package org.elasticsearch.index.shard
Class IndexSearcherWrapper
- java.lang.Object
-
- org.elasticsearch.index.shard.IndexSearcherWrapper
-
public class IndexSearcherWrapper extends java.lang.Object
Extension point to add custom functionality at request time to theDirectoryReader
andIndexSearcher
managed by theIndexShard
.
-
-
Constructor Summary
Constructors Constructor Description IndexSearcherWrapper()
-
Method Summary
Modifier and Type Method Description protected org.apache.lucene.index.DirectoryReader
wrap(org.apache.lucene.index.DirectoryReader reader)
Wraps the givenDirectoryReader
.protected org.apache.lucene.search.IndexSearcher
wrap(org.apache.lucene.search.IndexSearcher searcher)
Engine.Searcher
wrap(Engine.Searcher engineSearcher)
If there are configuredIndexSearcherWrapper
instances, theIndexSearcher
of the provided engine searcher gets wrapped and a newEngine.Searcher
instances is returned, otherwise the providedEngine.Searcher
is returned.
-
-
-
Method Detail
-
wrap
protected org.apache.lucene.index.DirectoryReader wrap(org.apache.lucene.index.DirectoryReader reader) throws java.io.IOException
Wraps the givenDirectoryReader
. 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 ofFilterDirectoryReader
that eventually exposes the original reader viaFilterDirectoryReader.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
-
wrap
public final Engine.Searcher wrap(Engine.Searcher engineSearcher) throws java.io.IOException
If there are configuredIndexSearcherWrapper
instances, theIndexSearcher
of the provided engine searcher gets wrapped and a newEngine.Searcher
instances is returned, otherwise the providedEngine.Searcher
is returned. This is invoked each time aEngine.Searcher
is requested to do an operation. (for example search)- Throws:
java.io.IOException
-
-