Package org.elasticsearch.index.shard
Class IndexSearcherWrapper
- java.lang.Object
-
- org.elasticsearch.index.shard.IndexSearcherWrapper
-
public class IndexSearcherWrapper extends java.lang.ObjectExtension point to add custom functionality at request time to theDirectoryReaderandIndexSearchermanaged by theIndexShard.
-
-
Constructor Summary
Constructors Constructor Description IndexSearcherWrapper()
-
Method Summary
Modifier and Type Method Description protected org.apache.lucene.index.DirectoryReaderwrap(org.apache.lucene.index.DirectoryReader reader)Wraps the givenDirectoryReader.protected org.apache.lucene.search.IndexSearcherwrap(org.apache.lucene.search.IndexSearcher searcher)Engine.Searcherwrap(Engine.Searcher engineSearcher)If there are configuredIndexSearcherWrapperinstances, theIndexSearcherof the provided engine searcher gets wrapped and a newEngine.Searcherinstances is returned, otherwise the providedEngine.Searcheris returned.
-
-
-
Method Detail
-
wrap
protected org.apache.lucene.index.DirectoryReader wrap(org.apache.lucene.index.DirectoryReader reader) throws java.io.IOExceptionWraps 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 ofFilterDirectoryReaderthat 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 configuredIndexSearcherWrapperinstances, theIndexSearcherof the provided engine searcher gets wrapped and a newEngine.Searcherinstances is returned, otherwise the providedEngine.Searcheris returned. This is invoked each time aEngine.Searcheris requested to do an operation. (for example search)- Throws:
java.io.IOException
-
-