org.apache.lucene.search.spans
Class OrNearSpans

Object
  extended by OrNearSpans
All Implemented Interfaces:
Spans

 class OrNearSpans
extends Object
implements Spans

Calculates spans that match several queries "near" each other. In-order matches score higher than out-of-order matches.


Nested Class Summary
private  class OrNearSpans.SpansCell
           
 
Field Summary
private static Comparator cellComparator
           
private  ArrayList cells
           
private  boolean firstTime
           
private  int matchDist
           
private  int matchEndCell
           
private  int matchNumCells
           
private  float matchTotalScore
           
private  boolean more
           
private  int nClauses
           
private  boolean penalizeOutOfOrder
           
private  SpanOrNearQuery query
           
private  Similarity similarity
           
private  int slop
           
 
Constructor Summary
OrNearSpans(SpanOrNearQuery query, IndexReader reader, Searcher searcher)
           
 
Method Summary
private  boolean advance(int skipTo)
           
 int doc()
          Returns the document number of the current match.
 int end()
          Returns the end position of the current match.
 Explanation explain()
          Returns an explanation of how the score was arrived at.
private  boolean initCells(int skipTo)
           
 boolean next()
          Move to the next match, returning true iff any such exists.
private  boolean nextCell()
           
 float score()
          Returns the score of the current match.
 boolean skipTo(int target)
          Skips to the first match beyond the current, whose document number is greater than or equal to target.
 int start()
          Returns the start position of the current match.
 String toString()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

query

private SpanOrNearQuery query

similarity

private Similarity similarity

nClauses

private int nClauses

cells

private ArrayList cells

slop

private int slop

penalizeOutOfOrder

private boolean penalizeOutOfOrder

more

private boolean more

firstTime

private boolean firstTime

matchDist

private int matchDist

matchTotalScore

private float matchTotalScore

matchEndCell

private int matchEndCell

matchNumCells

private int matchNumCells

cellComparator

private static final Comparator cellComparator
Constructor Detail

OrNearSpans

public OrNearSpans(SpanOrNearQuery query,
                   IndexReader reader,
                   Searcher searcher)
            throws IOException
Throws:
IOException
Method Detail

next

public boolean next()
             throws IOException
Description copied from interface: Spans
Move to the next match, returning true iff any such exists.

Specified by:
next in interface Spans
Throws:
IOException

initCells

private boolean initCells(int skipTo)
                   throws IOException
Throws:
IOException

advance

private boolean advance(int skipTo)
                 throws IOException
Throws:
IOException

nextCell

private boolean nextCell()

skipTo

public boolean skipTo(int target)
               throws IOException
Description copied from interface: Spans
Skips to the first match beyond the current, whose document number is greater than or equal to target.

Returns true iff there is such a match.

Behaves as if written:

   boolean skipTo(int target) {
     do {
       if (!next())
              return false;
     } while (target > doc());
     return true;
   }
 
Most implementations are considerably more efficient than that.

Specified by:
skipTo in interface Spans
Throws:
IOException

doc

public int doc()
Description copied from interface: Spans
Returns the document number of the current match. Initially invalid.

Specified by:
doc in interface Spans

start

public int start()
Description copied from interface: Spans
Returns the start position of the current match. Initially invalid.

Specified by:
start in interface Spans

end

public int end()
Description copied from interface: Spans
Returns the end position of the current match. Initially invalid.

Specified by:
end in interface Spans

score

public float score()
Description copied from interface: Spans
Returns the score of the current match. Initially invalid.

Specified by:
score in interface Spans

toString

public String toString()
Overrides:
toString in class Object

explain

public Explanation explain()
                    throws IOException
Description copied from interface: Spans
Returns an explanation of how the score was arrived at. Initially invalid.

Specified by:
explain in interface Spans
Throws:
IOException