org.apache.lucene.search.spans
Class SpanOrNearQuery

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

public class SpanOrNearQuery
extends SpanQuery

Matches spans which are near one another. Unlike a standard 'near' query, all of the sub-queries need not be present. One can specify slop, the maximum edit distance for those that are present in a given document. If enabled, in-order matches are scored higher than out-of-order.

See Also:
Serialized Form

Field Summary
private  SpanQuery[] clauses
           
private  String field
           
private  boolean penalizeOutOfOrder
           
private  int slop
           
 
Constructor Summary
SpanOrNearQuery(SpanQuery[] clauses, int slop, boolean penalizeOutOfOrder)
          Construct a SpanOrNearQuery.
 
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 penalizeOutOfOrder()
          Return true if matches are penalized for being out of 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 SpanQuery[] clauses

slop

private int slop

penalizeOutOfOrder

private boolean penalizeOutOfOrder

field

private String field
Constructor Detail

SpanOrNearQuery

public SpanOrNearQuery(SpanQuery[] clauses,
                       int slop,
                       boolean penalizeOutOfOrder)
Construct a SpanOrNearQuery. Matches spans matching a span from each clause if present, with up to slop total edit distance between them. When penalizeOutOfOrder is true, out of order clauses are scored lower than in-order 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.


penalizeOutOfOrder

public boolean penalizeOutOfOrder()
Return true if matches are penalized for being out of 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