Class MultiSearcher
- java.lang.Object
-
- org.apache.lucene.search.Searcher
-
- org.apache.lucene.search.MultiSearcher
-
- All Implemented Interfaces:
- java.rmi.Remote, Searchable
- Direct Known Subclasses:
- ParallelMultiSearcher
public class MultiSearcher extends Searcher
Implements search over a set ofSearchables.Applications usually need only call the inherited
Searcher.search(Query)orSearcher.search(Query,Filter)methods.
-
-
Constructor Summary
Constructors Constructor and Description MultiSearcher(Searchable[] searchables)Creates a searcher which searches searchables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Frees resources associated with this Searcher.Documentdoc(int n)Expert: Returns the stored fields of documenti.Documentdoc(int n, FieldSelector fieldSelector)Get theDocumentat thenth position.intdocFreq(Term term)Expert: Returns the number of documents containingterm.Explanationexplain(Weight weight, int doc)Expert: low-level implementation method Returns an Explanation that describes howdocscored againstweight.Searchable[]getSearchables()Return the array ofSearchables this searches.intmaxDoc()Expert: Returns one greater than the largest possible document number.Queryrewrite(Query original)Expert: called to re-write queries into primitive queries.voidsearch(Weight weight, Filter filter, HitCollector results)Lower-level search API.TopDocssearch(Weight weight, Filter filter, int nDocs)Expert: Low-level search implementation.TopFieldDocssearch(Weight weight, Filter filter, int n, Sort sort)Expert: Low-level search implementation with arbitrary sorting.intsubDoc(int n)Returns the document number of documentnwithin its sub-index.intsubSearcher(int n)Returns index of the searcher for documentnin the array used to construct this searcher.
-
-
-
Constructor Detail
-
MultiSearcher
public MultiSearcher(Searchable[] searchables) throws java.io.IOException
Creates a searcher which searches searchables.- Throws:
java.io.IOException
-
-
Method Detail
-
getSearchables
public Searchable[] getSearchables()
Return the array ofSearchables this searches.
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:SearchableFrees resources associated with this Searcher. Be careful not to call this method while you are still using objects likeHits.- Specified by:
closein interfaceSearchable- Specified by:
closein classSearcher- Throws:
java.io.IOException
-
docFreq
public int docFreq(Term term) throws java.io.IOException
Description copied from interface:SearchableExpert: Returns the number of documents containingterm. Called by search code to compute term weights.- Specified by:
docFreqin interfaceSearchable- Specified by:
docFreqin classSearcher- Throws:
java.io.IOException- See Also:
IndexReader.docFreq(Term)
-
doc
public Document doc(int n) throws CorruptIndexException, java.io.IOException
Description copied from interface:SearchableExpert: Returns the stored fields of documenti. Called byHitCollectorimplementations.- Specified by:
docin interfaceSearchable- Specified by:
docin classSearcher- Throws:
CorruptIndexException- if the index is corruptjava.io.IOException- if there is a low-level IO error- See Also:
IndexReader.document(int)
-
doc
public Document doc(int n, FieldSelector fieldSelector) throws CorruptIndexException, java.io.IOException
Description copied from interface:SearchableGet theDocumentat thenth position. TheFieldSelectormay be used to determine whatFields to load and how they should be loaded. NOTE: If the underlying Reader (more specifically, the underlyingFieldsReader) is closed before the lazyFieldis loaded an exception may be thrown. If you want the value of a lazyFieldto be available after closing you must explicitly load it or fetch the Document again with a new loader.- Parameters:
n- Get the document at thenth positionfieldSelector- TheFieldSelectorto use to determine what Fields should be loaded on the Document. May be null, in which case all Fields will be loaded.- Returns:
- The stored fields of the
Documentat the nth position - Throws:
CorruptIndexException- if the index is corruptjava.io.IOException- if there is a low-level IO error- See Also:
IndexReader.document(int, FieldSelector),Fieldable,FieldSelector,SetBasedFieldSelector,LoadFirstFieldSelector
-
subSearcher
public int subSearcher(int n)
Returns index of the searcher for documentnin the array used to construct this searcher.
-
subDoc
public int subDoc(int n)
Returns the document number of documentnwithin its sub-index.
-
maxDoc
public int maxDoc() throws java.io.IOExceptionDescription copied from interface:SearchableExpert: Returns one greater than the largest possible document number. Called by search code to compute term weights.- Specified by:
maxDocin interfaceSearchable- Specified by:
maxDocin classSearcher- Throws:
java.io.IOException- See Also:
IndexReader.maxDoc()
-
search
public TopDocs search(Weight weight, Filter filter, int nDocs) throws java.io.IOException
Description copied from interface:SearchableExpert: Low-level search implementation. Finds the topnhits forquery, applyingfilterif non-null.Called by
Hits.Applications should usually call
Searcher.search(Query)orSearcher.search(Query,Filter)instead.- Specified by:
searchin interfaceSearchable- Specified by:
searchin classSearcher- Throws:
java.io.IOException
-
search
public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort) throws java.io.IOException
Description copied from interface:SearchableExpert: Low-level search implementation with arbitrary sorting. Finds the topnhits forquery, applyingfilterif non-null, and sorting the hits by the criteria insort.Applications should usually call
Searcher.search(Query,Filter,Sort)instead.- Specified by:
searchin interfaceSearchable- Specified by:
searchin classSearcher- Throws:
java.io.IOException
-
search
public void search(Weight weight, Filter filter, HitCollector results) throws java.io.IOException
Description copied from interface:SearchableLower-level search API.HitCollector.collect(int,float)is called for every non-zero scoring document.
HitCollector-based access to remote indexes is discouraged.Applications should only use this if they need all of the matching documents. The high-level search API (
Searcher.search(Query)) is usually more efficient, as it skips non-high-scoring hits.- Specified by:
searchin interfaceSearchable- Specified by:
searchin classSearcher- Parameters:
weight- to match documentsfilter- if non-null, a bitset used to eliminate some documentsresults- to receive hits- Throws:
java.io.IOException
-
rewrite
public Query rewrite(Query original) throws java.io.IOException
Description copied from interface:SearchableExpert: called to re-write queries into primitive queries.- Specified by:
rewritein interfaceSearchable- Specified by:
rewritein classSearcher- Throws:
java.io.IOException
-
explain
public Explanation explain(Weight weight, int doc) throws java.io.IOException
Description copied from interface:SearchableExpert: low-level implementation method Returns an Explanation that describes howdocscored againstweight.This is intended to be used in developing Similarity implementations, and, for good performance, should not be displayed with every hit. Computing an explanation is as expensive as executing the query over the entire index.
Applications should call
Searcher.explain(Query, int).- Specified by:
explainin interfaceSearchable- Specified by:
explainin classSearcher- Throws:
java.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG