org.apache.lucene.search.spans
Class SpanNearQuery

Object
  extended by Query
      extended by SpanQuery
          extended by SpanNearQuery
All Implemented Interfaces:
Serializable, Cloneable

public class SpanNearQuery
extends SpanQuery

Matches spans which are near one another. One can specify slop, the maximum edit distance, as well as whether matches are required to be in-order. In-order matches are scored higher than out-of-order.

See Also:
Serialized Form

Field Summary
private  List clauses
           
private  String field
           
private  boolean inOrder
           
private  int slop
           
 
Constructor Summary
SpanNearQuery(SpanQuery[] clauses, int slop, boolean inOrder)
          Construct a SpanNearQuery.
 
Method Summary
 SpanQuery[] getClauses()
          Return the clauses whose spans are matched.
 String getField()
          Returns the name of the field matched by this query.
 int getSlop()
          Return the maximum number of intervening unmatched positions permitted.
 Spans getSpans(IndexReader reader, Searcher searcher)
          Expert: Returns the matches for this query in an index.
 Query[] getSubQueries()
           
 Collection getTerms()
          Returns a collection of all terms matched by this query.
 boolean isInOrder()
          Return true if matches are required to be in-order.
 Query rewrite(IndexReader reader)
           
 void setSlop(int slop)
          Set the maximum edit distance permitted.
 String toString(String field)
           
 
Methods inherited from class SpanQuery
createWeight, getSpanRecording, setSpanRecording
 
Methods inherited from class Query
clone, combine, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

clauses

private List clauses

slop

private int slop

inOrder

private boolean inOrder

field

private String field
Constructor Detail

SpanNearQuery

public SpanNearQuery(SpanQuery[] clauses,
                     int slop,
                     boolean inOrder)
Construct a SpanNearQuery. Matches spans matching a span from each clause, with up to slop total edit distance between them. When inOrder is true, the spans from each clause must be ordered as in clauses.

Method Detail

getClauses

public SpanQuery[] getClauses()
Return the clauses whose spans are matched.


getSlop

public int getSlop()
Return the maximum number of intervening unmatched positions permitted.


isInOrder

public boolean isInOrder()
Return true if matches are required to be in-order.


setSlop

public void setSlop(int slop)
Set the maximum edit distance permitted.


getField

public String getField()
Description copied from class: SpanQuery
Returns the name of the field matched by this query.

Specified by:
getField in class SpanQuery

getTerms

public Collection getTerms()
Description copied from class: SpanQuery
Returns a collection of all terms matched by this query.

Specified by:
getTerms in class SpanQuery

getSubQueries

public Query[] getSubQueries()

rewrite

public Query rewrite(IndexReader reader)
              throws IOException
Overrides:
rewrite in class Query
Throws:
IOException

toString

public String toString(String field)
Specified by:
toString in class Query

getSpans

public Spans getSpans(IndexReader reader,
                      Searcher searcher)
               throws IOException
Description copied from class: SpanQuery
Expert: Returns the matches for this query in an index. Used internally to search for spans.

Specified by:
getSpans in class SpanQuery
Throws:
IOException