gate.creole.annic.apache.lucene.search
Class PhraseQuery

java.lang.Object
  extended by gate.creole.annic.apache.lucene.search.Query
      extended by gate.creole.annic.apache.lucene.search.PhraseQuery
All Implemented Interfaces:
Serializable, Cloneable

public class PhraseQuery
extends Query

A Query that matches documents containing a particular sequence of terms. This may be combined with other terms with a BooleanQuery.

See Also:
Serialized Form

Constructor Summary
PhraseQuery()
          Constructs an empty phrase query.
 
Method Summary
 void add(Term term)
           
 void add(Term term, Integer position, boolean considerAsATerm)
          Adds a term to the end of the query phrase.
protected  Weight createWeight(Searcher searcher)
          Expert: Constructs an appropriate Weight implementation for this query.
 boolean equals(Object o)
          Returns true iff o is equal to this.
 int getSlop()
          Returns the slop.
 Term[] getTerms()
          Returns the set of terms in this phrase.
 int hashCode()
          Returns a hash code value for this object.
 void setSlop(int s)
          Sets the number of other words permitted between words in query phrase.
 void setTotalTerms(int totalTerms)
           
 String toString(String f)
          Prints a user-readable version of this query.
 
Methods inherited from class gate.creole.annic.apache.lucene.search.Query
clone, combine, getBoost, getSimilarity, mergeBooleanQueries, rewrite, setBoost, toString, weight
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PhraseQuery

public PhraseQuery()
Constructs an empty phrase query.

Method Detail

setSlop

public void setSlop(int s)
Sets the number of other words permitted between words in query phrase. If zero, then this is an exact phrase search. For larger values this works like a WITHIN or NEAR operator.

The slop is in fact an edit-distance, where the units correspond to moves of terms in the query phrase out of position. For example, to switch the order of two words requires two moves (the first move places the words atop one another), so to permit re-orderings of phrases, the slop must be at least two.

More exact matches are scored higher than sloppier matches, thus search results are sorted by exactness.

The slop is zero by default, requiring exact matches.


getSlop

public int getSlop()
Returns the slop. See setSlop().


add

public void add(Term term,
                Integer position,
                boolean considerAsATerm)
Adds a term to the end of the query phrase.


setTotalTerms

public void setTotalTerms(int totalTerms)

add

public void add(Term term)

getTerms

public Term[] getTerms()
Returns the set of terms in this phrase.


createWeight

protected Weight createWeight(Searcher searcher)
Description copied from class: Query
Expert: Constructs an appropriate Weight implementation for this query.

Only implemented by primitive queries, which re-write to themselves.

Overrides:
createWeight in class Query

toString

public String toString(String f)
Prints a user-readable version of this query.

Specified by:
toString in class Query

equals

public boolean equals(Object o)
Returns true iff o is equal to this.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object