Package org.apache.lucene.queries.spans
Class Spans
- java.lang.Object
-
- org.apache.lucene.search.DocIdSetIterator
-
- org.apache.lucene.queries.spans.Spans
-
- Direct Known Subclasses:
FilterSpans,NearSpansOrdered,NearSpansUnordered,TermSpans
public abstract class Spans extends DocIdSetIterator
Iterates through combinations of start/end positions per-doc. Each start/end position represents a range of term positions within the current document. These are enumerated in order, by increasing document number, within that by increasing start position and finally by increasing end position.
-
-
Field Summary
Fields Modifier and Type Field Description static intNO_MORE_POSITIONS-
Fields inherited from class org.apache.lucene.search.DocIdSetIterator
NO_MORE_DOCS
-
-
Constructor Summary
Constructors Constructor Description Spans()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TwoPhaseIteratorasTwoPhaseIterator()Optional method: Return aTwoPhaseIteratorview of thisScorer.abstract voidcollect(SpanCollector collector)Collect postings data from the leaves of the current Spans.protected voiddoCurrentSpans()Called each time the scorer's SpanScorer is advanced during frequency calculationprotected voiddoStartCurrentDoc()Called before the current doc's frequency is calculatedabstract intendPosition()Returns the end position for the current start position, or -1 whennextStartPosition()was not yet called on the current doc.abstract intnextStartPosition()Returns the next start position for the current doc.abstract floatpositionsCost()Return an estimation of the cost of using the positions of thisSpansfor any single document, but only afterasTwoPhaseIterator()returnednull.abstract intstartPosition()Returns the start position in the current doc, or -1 whennextStartPosition()was not yet called on the current doc.StringtoString()abstract intwidth()Return the width of the match, which is typically used to sloppy freq.-
Methods inherited from class org.apache.lucene.search.DocIdSetIterator
advance, all, cost, docID, empty, nextDoc, range, slowAdvance
-
-
-
-
Field Detail
-
NO_MORE_POSITIONS
public static final int NO_MORE_POSITIONS
- See Also:
- Constant Field Values
-
-
Method Detail
-
nextStartPosition
public abstract int nextStartPosition() throws IOExceptionReturns the next start position for the current doc. There is always at least one start/end position per doc. After the last start/end position at the current doc this returnsNO_MORE_POSITIONS.- Throws:
IOException
-
startPosition
public abstract int startPosition()
Returns the start position in the current doc, or -1 whennextStartPosition()was not yet called on the current doc. After the last start/end position at the current doc this returnsNO_MORE_POSITIONS.
-
endPosition
public abstract int endPosition()
Returns the end position for the current start position, or -1 whennextStartPosition()was not yet called on the current doc. After the last start/end position at the current doc this returnsNO_MORE_POSITIONS.
-
width
public abstract int width()
Return the width of the match, which is typically used to sloppy freq. It is only legal to call this method when the iterator is on a valid doc ID and positioned. The return value must be positive, and lower values means that the match is better.
-
collect
public abstract void collect(SpanCollector collector) throws IOException
Collect postings data from the leaves of the current Spans.This method should only be called after
nextStartPosition(), and beforeNO_MORE_POSITIONShas been reached.- Parameters:
collector- a SpanCollector- Throws:
IOException- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
positionsCost
public abstract float positionsCost()
Return an estimation of the cost of using the positions of thisSpansfor any single document, but only afterasTwoPhaseIterator()returnednull. Otherwise this method should not be called. The returned value is independent of the current document.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
asTwoPhaseIterator
public TwoPhaseIterator asTwoPhaseIterator()
Optional method: Return aTwoPhaseIteratorview of thisScorer. A return value ofnullindicates that two-phase iteration is not supported.- See Also:
Scorer.twoPhaseIterator()
-
doStartCurrentDoc
protected void doStartCurrentDoc() throws IOExceptionCalled before the current doc's frequency is calculated- Throws:
IOException
-
doCurrentSpans
protected void doCurrentSpans() throws IOExceptionCalled each time the scorer's SpanScorer is advanced during frequency calculation- Throws:
IOException
-
-