Class LuIndexSearcher
- java.lang.Object
-
- org.apache.lucene.search.IndexSearcher
-
- ai.preferred.cerebro.index.search.structure.LuIndexSearcher
-
- All Implemented Interfaces:
VersatileSearcher
public class LuIndexSearcher extends org.apache.lucene.search.IndexSearcher implements VersatileSearcher
Inherited from Lucene's IndexSearcher, this class extends Lucene's traditional full-text search to vector similarity search also. As such it shares almost all of Lucene's IndexSearcher; from thread-safety to I/O speed. Use it as you would use a Lucene searcher. Plus, it now supports vector similarity search viaqueryVector(double[], int)
.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ExecutorService
executor
protected org.apache.lucene.search.IndexSearcher.LeafSlice[]
leafSlices
protected org.apache.lucene.index.IndexReader
reader
-
Constructor Summary
Constructors Constructor Description LuIndexSearcher(org.apache.lucene.index.IndexReaderContext context, java.util.concurrent.ExecutorService executor, java.lang.String splitVecPath)
LuIndexSearcher(org.apache.lucene.index.IndexReader r, java.lang.String splitVecPath)
Create a searcher from the provided index and set of hashing vectors.LuIndexSearcher(org.apache.lucene.index.IndexReader r, java.util.concurrent.ExecutorService executor, java.lang.String splitVecPath)
Runs searches for each segment separately, using the provided ExecutorService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.lucene.search.ScoreDoc[]
queryKeyWord(org.apache.lucene.queryparser.classic.QueryParser queryParser, java.lang.String sQuery, int resultSize)
org.apache.lucene.search.ScoreDoc[]
queryVector(double[] vQuery, int resultSize)
-
Methods inherited from class org.apache.lucene.search.IndexSearcher
collectionStatistics, count, createNormalizedWeight, createWeight, doc, doc, doc, explain, explain, getDefaultQueryCache, getDefaultQueryCachingPolicy, getDefaultSimilarity, getIndexReader, getQueryCache, getQueryCachingPolicy, getSimilarity, getSlices, getTopReaderContext, rewrite, search, search, search, search, search, search, searchAfter, searchAfter, searchAfter, setDefaultQueryCache, setDefaultQueryCachingPolicy, setQueryCache, setQueryCachingPolicy, setSimilarity, slices, termStatistics, toString
-
-
-
-
Constructor Detail
-
LuIndexSearcher
public LuIndexSearcher(org.apache.lucene.index.IndexReader r, java.lang.String splitVecPath) throws java.io.IOException
Create a searcher from the provided index and set of hashing vectors.- Throws:
java.io.IOException
-
LuIndexSearcher
public LuIndexSearcher(org.apache.lucene.index.IndexReader r, java.util.concurrent.ExecutorService executor, java.lang.String splitVecPath) throws java.io.IOException
Runs searches for each segment separately, using the provided ExecutorService. IndexSearcher will not close/awaitTermination this ExecutorService on close; you must do so, eventually, on your own. NOTE: if you are usingNIOFSDirectory
, do not use the shutdownNow method of ExecutorService as this uses Thread.interrupt under-the-hood which can silently close file descriptors (see LUCENE-2239).- Throws:
java.io.IOException
-
LuIndexSearcher
public LuIndexSearcher(org.apache.lucene.index.IndexReaderContext context, java.util.concurrent.ExecutorService executor, java.lang.String splitVecPath) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
queryKeyWord
public org.apache.lucene.search.ScoreDoc[] queryKeyWord(org.apache.lucene.queryparser.classic.QueryParser queryParser, java.lang.String sQuery, int resultSize) throws java.lang.Exception
- Specified by:
queryKeyWord
in interfaceVersatileSearcher
- Parameters:
queryParser
- if null the searcher will by default carry search on the field namedIndexConst.CONTENTS
.sQuery
-resultSize
-- Returns:
- A set of
ScoreDoc
of Document matching with the query. - Throws:
java.lang.Exception
-
queryVector
public org.apache.lucene.search.ScoreDoc[] queryVector(double[] vQuery, int resultSize) throws java.lang.Exception
- Specified by:
queryVector
in interfaceVersatileSearcher
- Parameters:
vQuery
-resultSize
-- Returns:
- A set of
ScoreDoc
of Document having latent vector producing. the highest inner product with the query vector. - Throws:
java.lang.Exception
-
-