com.lucene.search
Class PhraseQuery

java.lang.Object
  |
  +--com.lucene.search.Query
        |
        +--com.lucene.search.PhraseQuery

public final 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.


Constructor Summary
PhraseQuery()
          Constructs an empty phrase query.
 
Method Summary
 void add(Term term)
          Adds a term to the end of the query phrase.
 float getBoost()
          Gets the boost for this term.
 int getSlop()
          Returns the slop.
 void setBoost(float b)
          Sets the boost for this term to b.
 void setSlop(int s)
          Sets the number of other words permitted between words in query phrase.
 String toString(String f)
          Prints a user-readable version of this query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhraseQuery

public PhraseQuery()
Constructs an empty phrase query.
Method Detail

setBoost

public final void setBoost(float b)
Sets the boost for this term to b. Documents containing this term will (in addition to the normal weightings) have their score multiplied by b.

getBoost

public final float getBoost()
Gets the boost for this term. Documents containing this term will (in addition to the normal weightings) have their score multiplied by b. The boost is 1.0 by default.

setSlop

public final 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 final int getSlop()
Returns the slop. See setSlop().

add

public final void add(Term term)
Adds a term to the end of the query phrase.

toString

public final String toString(String f)
Prints a user-readable version of this query.
Overrides:
toString in class Query