Package org.apache.lucene.search
Class BooleanScorer
- java.lang.Object
-
- org.apache.lucene.search.BulkScorer
-
- org.apache.lucene.search.BooleanScorer
-
final class BooleanScorer extends BulkScorer
BulkScorerthat is used for pure disjunctions and disjunctions that have low values ofBooleanQuery.Builder.setMinimumNumberShouldMatch(int)and dense clauses. This scorer scores documents by batches of 2048 docs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classBooleanScorer.Bucketprivate classBooleanScorer.BulkScorerAndDoc(package private) static classBooleanScorer.HeadPriorityQueue(package private) classBooleanScorer.OrCollector(package private) static classBooleanScorer.TailPriorityQueue
-
Field Summary
Fields Modifier and Type Field Description (package private) BooleanScorer.Bucket[]buckets(package private) longcost(package private) BooleanScorer.HeadPriorityQueuehead(package private) BooleanScorer.BulkScorerAndDoc[]leads(package private) static intMASK(package private) long[]matching(package private) intminShouldMatch(package private) BooleanScorer.OrCollectororCollector(package private) ScoreAndDocscoreAndDoc(package private) static intSET_MASK(package private) static intSET_SIZE(package private) static intSHIFT(package private) static intSIZE(package private) BooleanScorer.TailPriorityQueuetail
-
Constructor Summary
Constructors Constructor Description BooleanScorer(BooleanWeight weight, java.util.Collection<BulkScorer> scorers, int minShouldMatch, boolean needsScores)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private BooleanScorer.BulkScorerAndDocadvance(int min)longcost()Same asDocIdSetIterator.cost()for bulk scorers.private static longcost(java.util.Collection<BulkScorer> scorers, int minShouldMatch)intscore(LeafCollector collector, Bits acceptDocs, int min, int max)Collects matching documents in a range and return an estimation of the next matching document which is on or aftermax.private voidscoreDocument(LeafCollector collector, int base, int i)private voidscoreMatches(LeafCollector collector, int base)private BooleanScorer.BulkScorerAndDocscoreWindow(BooleanScorer.BulkScorerAndDoc top, LeafCollector collector, Bits acceptDocs, int min, int max)private voidscoreWindowIntoBitSetAndReplay(LeafCollector collector, Bits acceptDocs, int base, int min, int max, BooleanScorer.BulkScorerAndDoc[] scorers, int numScorers)private voidscoreWindowMultipleScorers(LeafCollector collector, Bits acceptDocs, int windowBase, int windowMin, int windowMax, int maxFreq)private voidscoreWindowSingleScorer(BooleanScorer.BulkScorerAndDoc bulkScorer, LeafCollector collector, Bits acceptDocs, int windowMin, int windowMax, int max)-
Methods inherited from class org.apache.lucene.search.BulkScorer
score
-
-
-
-
Field Detail
-
SHIFT
static final int SHIFT
- See Also:
- Constant Field Values
-
SIZE
static final int SIZE
- See Also:
- Constant Field Values
-
MASK
static final int MASK
- See Also:
- Constant Field Values
-
SET_SIZE
static final int SET_SIZE
- See Also:
- Constant Field Values
-
SET_MASK
static final int SET_MASK
- See Also:
- Constant Field Values
-
buckets
final BooleanScorer.Bucket[] buckets
-
matching
final long[] matching
-
leads
final BooleanScorer.BulkScorerAndDoc[] leads
-
head
final BooleanScorer.HeadPriorityQueue head
-
tail
final BooleanScorer.TailPriorityQueue tail
-
scoreAndDoc
final ScoreAndDoc scoreAndDoc
-
minShouldMatch
final int minShouldMatch
-
cost
final long cost
-
orCollector
final BooleanScorer.OrCollector orCollector
-
-
Constructor Detail
-
BooleanScorer
BooleanScorer(BooleanWeight weight, java.util.Collection<BulkScorer> scorers, int minShouldMatch, boolean needsScores)
-
-
Method Detail
-
cost
private static long cost(java.util.Collection<BulkScorer> scorers, int minShouldMatch)
-
cost
public long cost()
Description copied from class:BulkScorerSame asDocIdSetIterator.cost()for bulk scorers.- Specified by:
costin classBulkScorer
-
scoreDocument
private void scoreDocument(LeafCollector collector, int base, int i) throws java.io.IOException
- Throws:
java.io.IOException
-
scoreMatches
private void scoreMatches(LeafCollector collector, int base) throws java.io.IOException
- Throws:
java.io.IOException
-
scoreWindowIntoBitSetAndReplay
private void scoreWindowIntoBitSetAndReplay(LeafCollector collector, Bits acceptDocs, int base, int min, int max, BooleanScorer.BulkScorerAndDoc[] scorers, int numScorers) throws java.io.IOException
- Throws:
java.io.IOException
-
advance
private BooleanScorer.BulkScorerAndDoc advance(int min) throws java.io.IOException
- Throws:
java.io.IOException
-
scoreWindowMultipleScorers
private void scoreWindowMultipleScorers(LeafCollector collector, Bits acceptDocs, int windowBase, int windowMin, int windowMax, int maxFreq) throws java.io.IOException
- Throws:
java.io.IOException
-
scoreWindowSingleScorer
private void scoreWindowSingleScorer(BooleanScorer.BulkScorerAndDoc bulkScorer, LeafCollector collector, Bits acceptDocs, int windowMin, int windowMax, int max) throws java.io.IOException
- Throws:
java.io.IOException
-
scoreWindow
private BooleanScorer.BulkScorerAndDoc scoreWindow(BooleanScorer.BulkScorerAndDoc top, LeafCollector collector, Bits acceptDocs, int min, int max) throws java.io.IOException
- Throws:
java.io.IOException
-
score
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws java.io.IOException
Description copied from class:BulkScorerCollects matching documents in a range and return an estimation of the next matching document which is on or aftermax.The return value must be:
- >=
max, DocIdSetIterator.NO_MORE_DOCSif there are no more matches,- <= the first matching document that is >=
maxotherwise.
minis the minimum document to be considered for matching. All documents strictly before this value must be ignored.Although
maxwould be a legal return value for this method, higher values might help callers skip more efficiently over non-matching portions of the docID space.For instance, a
Scorer-based implementation could look like below:private final Scorer scorer; // set via constructor public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException { collector.setScorer(scorer); int doc = scorer.docID(); if (doc < min) { doc = scorer.advance(min); } while (doc < max) { if (acceptDocs == null || acceptDocs.get(doc)) { collector.collect(doc); } doc = scorer.nextDoc(); } return doc; }- Specified by:
scorein classBulkScorer- Parameters:
collector- The collector to which all matching documents are passed.acceptDocs-Bitsthat represents the allowed documents to match, ornullif they are all allowed to match.min- Score starting at, including, this documentmax- Score up to, but not including, this doc- Returns:
- an under-estimation of the next matching doc after max
- Throws:
java.io.IOException
- >=
-
-