Class FacetsCollector
- java.lang.Object
-
- org.apache.lucene.search.Collector
-
- org.apache.lucene.facet.FacetsCollector
-
public class FacetsCollector extends Collector
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FacetsCollector.MatchingDocs
Holds the documents that were matched in theAtomicReaderContext
.
-
Constructor Summary
Constructors Constructor Description FacetsCollector()
Default constructorFacetsCollector(boolean keepScores)
Create this; ifkeepScores
is true then a float[] is allocated to hold score of all hits.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptsDocsOutOfOrder()
Returntrue
if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) toCollector.collect(int)
.void
collect(int doc)
Called once for every document matching a query, with the unbased document number.boolean
getKeepScores()
True if scores were saved.java.util.List<FacetsCollector.MatchingDocs>
getMatchingDocs()
Returns the documents matched by the query, oneFacetsCollector.MatchingDocs
per visited segment.static TopDocs
search(IndexSearcher searcher, Query q, int n, Collector fc)
Utility method, to search and also collect all hits into the providedCollector
.static TopDocs
search(IndexSearcher searcher, Query q, Filter filter, int n, Collector fc)
Utility method, to search and also collect all hits into the providedCollector
.static TopFieldDocs
search(IndexSearcher searcher, Query q, Filter filter, int n, Sort sort, boolean doDocScores, boolean doMaxScore, Collector fc)
Utility method, to search and also collect all hits into the providedCollector
.static TopFieldDocs
search(IndexSearcher searcher, Query q, Filter filter, int n, Sort sort, Collector fc)
Utility method, to search and also collect all hits into the providedCollector
.TopDocs
searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, int n, Collector fc)
Utility method, to search and also collect all hits into the providedCollector
.static TopDocs
searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, Collector fc)
Utility method, to search and also collect all hits into the providedCollector
.static TopDocs
searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, Sort sort, boolean doDocScores, boolean doMaxScore, Collector fc)
Utility method, to search and also collect all hits into the providedCollector
.static TopDocs
searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, Sort sort, Collector fc)
Utility method, to search and also collect all hits into the providedCollector
.void
setNextReader(AtomicReaderContext context)
Called before collecting from eachAtomicReaderContext
.void
setScorer(Scorer scorer)
Called before successive calls toCollector.collect(int)
.
-
-
-
Method Detail
-
getKeepScores
public final boolean getKeepScores()
True if scores were saved.
-
getMatchingDocs
public java.util.List<FacetsCollector.MatchingDocs> getMatchingDocs()
Returns the documents matched by the query, oneFacetsCollector.MatchingDocs
per visited segment.
-
acceptsDocsOutOfOrder
public final boolean acceptsDocsOutOfOrder()
Description copied from class:Collector
Returntrue
if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) toCollector.collect(int)
.Most Lucene Query implementations will visit matching docIDs in order. However, some queries (currently limited to certain cases of
BooleanQuery
) can achieve faster searching if theCollector
allows them to deliver the docIDs out of order.Many collectors don't mind getting docIDs out of order, so it's important to return
true
here.- Specified by:
acceptsDocsOutOfOrder
in classCollector
-
collect
public final void collect(int doc) throws java.io.IOException
Description copied from class:Collector
Called once for every document matching a query, with the unbased document number.Note: The collection of the current segment can be terminated by throwing a
CollectionTerminatedException
. In this case, the last docs of the currentAtomicReaderContext
will be skipped andIndexSearcher
will swallow the exception and continue collection with the next leaf.Note: This is called in an inner search loop. For good search performance, implementations of this method should not call
IndexSearcher.doc(int)
orIndexReader.document(int)
on every hit. Doing so can slow searches by an order of magnitude or more.
-
setScorer
public final void setScorer(Scorer scorer) throws java.io.IOException
Description copied from class:Collector
Called before successive calls toCollector.collect(int)
. Implementations that need the score of the current document (passed-in toCollector.collect(int)
), should save the passed-in Scorer and call scorer.score() when needed.
-
setNextReader
public final void setNextReader(AtomicReaderContext context) throws java.io.IOException
Description copied from class:Collector
Called before collecting from eachAtomicReaderContext
. All doc ids inCollector.collect(int)
will correspond toIndexReaderContext.reader()
. AddAtomicReaderContext.docBase
to the currentIndexReaderContext.reader()
's internal document id to re-base ids inCollector.collect(int)
.- Specified by:
setNextReader
in classCollector
- Parameters:
context
- next atomic reader context- Throws:
java.io.IOException
-
search
public static TopDocs search(IndexSearcher searcher, Query q, int n, Collector fc) throws java.io.IOException
Utility method, to search and also collect all hits into the providedCollector
.- Throws:
java.io.IOException
-
search
public static TopDocs search(IndexSearcher searcher, Query q, Filter filter, int n, Collector fc) throws java.io.IOException
Utility method, to search and also collect all hits into the providedCollector
.- Throws:
java.io.IOException
-
search
public static TopFieldDocs search(IndexSearcher searcher, Query q, Filter filter, int n, Sort sort, Collector fc) throws java.io.IOException
Utility method, to search and also collect all hits into the providedCollector
.- Throws:
java.io.IOException
-
search
public static TopFieldDocs search(IndexSearcher searcher, Query q, Filter filter, int n, Sort sort, boolean doDocScores, boolean doMaxScore, Collector fc) throws java.io.IOException
Utility method, to search and also collect all hits into the providedCollector
.- Throws:
java.io.IOException
-
searchAfter
public TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, int n, Collector fc) throws java.io.IOException
Utility method, to search and also collect all hits into the providedCollector
.- Throws:
java.io.IOException
-
searchAfter
public static TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, Collector fc) throws java.io.IOException
Utility method, to search and also collect all hits into the providedCollector
.- Throws:
java.io.IOException
-
searchAfter
public static TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, Sort sort, Collector fc) throws java.io.IOException
Utility method, to search and also collect all hits into the providedCollector
.- Throws:
java.io.IOException
-
searchAfter
public static TopDocs searchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, Sort sort, boolean doDocScores, boolean doMaxScore, Collector fc) throws java.io.IOException
Utility method, to search and also collect all hits into the providedCollector
.- Throws:
java.io.IOException
-
-