org.apache.lucene.search.spans
Class NearSpans

Object
  extended by NearSpans
All Implemented Interfaces:
Spans

 class NearSpans
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 NearSpans.SpansCell
          Wraps a Spans, and can be used to form a linked list.
 
Field Summary
private  NearSpans.SpansCell firstCell
           
private  boolean firstTime
           
private  boolean inOrder
           
private  NearSpans.SpansCell lastCell
           
private  boolean more
           
private  int nCellsInList
           
private  List ordered
           
private  SpanNearQuery query
           
private  Similarity similarity
           
private  int slop
           
private  int totalLength
           
private  float totalScore
           
private  int totalSlop
           
 
Constructor Summary
NearSpans(SpanNearQuery query, IndexReader reader, Searcher searcher)
           
 
Method Summary
private  boolean advanceOneCell()
           
private  boolean atMatch()
           
private  boolean checkSlop()
           
 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  void initList(int target)
           
private  boolean matchIsOrdered()
           
 boolean next()
          Move to the next match, returning true iff any such exists.
 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()
           
private  int totalSlop()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

query

private SpanNearQuery query

similarity

private Similarity similarity

ordered

private List ordered

slop

private int slop

inOrder

private boolean inOrder

firstCell

private NearSpans.SpansCell firstCell

lastCell

private NearSpans.SpansCell lastCell

nCellsInList

private int nCellsInList

totalLength

private int totalLength

totalScore

private float totalScore

totalSlop

private int totalSlop

more

private boolean more

firstTime

private boolean firstTime
Constructor Detail

NearSpans

public NearSpans(SpanNearQuery 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

advanceOneCell

private boolean advanceOneCell()
                        throws IOException
Throws:
IOException

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

initList

private void initList(int target)
               throws IOException
Throws:
IOException

atMatch

private boolean atMatch()

checkSlop

private boolean checkSlop()

matchIsOrdered

private boolean matchIsOrdered()

totalSlop

private int totalSlop()

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