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
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 inherited from class org.apache.lucene.search.DocIdSetIterator
NO_MORE_DOCS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionOptional method: Return aTwoPhaseIterator
view of thisScorer
.abstract void
collect
(SpanCollector collector) Collect postings data from the leaves of the current Spans.protected void
Called each time the scorer's SpanScorer is advanced during frequency calculationprotected void
Called before the current doc's frequency is calculatedabstract int
Returns the end position for the current start position, or -1 whennextStartPosition()
was not yet called on the current doc.abstract int
Returns the next start position for the current doc.abstract float
Return an estimation of the cost of using the positions of thisSpans
for any single document, but only afterasTwoPhaseIterator()
returnednull
.abstract int
Returns the start position in the current doc, or -1 whennextStartPosition()
was not yet called on the current doc.toString()
abstract int
width()
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 Details
-
NO_MORE_POSITIONS
public static final int NO_MORE_POSITIONS- See Also:
-
-
Constructor Details
-
Spans
public Spans()
-
-
Method Details
-
nextStartPosition
Returns 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
Collect postings data from the leaves of the current Spans.This method should only be called after
nextStartPosition()
, and beforeNO_MORE_POSITIONS
has 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 thisSpans
for 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
Optional method: Return aTwoPhaseIterator
view of thisScorer
. A return value ofnull
indicates that two-phase iteration is not supported.- See Also:
-
toString
-
doStartCurrentDoc
Called before the current doc's frequency is calculated- Throws:
IOException
-
doCurrentSpans
Called each time the scorer's SpanScorer is advanced during frequency calculation- Throws:
IOException
-