Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.PhraseQuery
public class PhraseQuery
extends Query
"new york"
.
This query may be combined with other terms or queries with a BooleanQuery
.
Constructor Summary | |
|
Method Summary | |
void | |
void | |
protected Weight |
|
boolean |
|
void |
|
int[] |
|
int |
|
Term[] |
|
int |
|
void |
|
String |
|
Methods inherited from class org.apache.lucene.search.Query | |
clone , combine , createWeight , extractTerms , getBoost , getSimilarity , mergeBooleanQueries , rewrite , setBoost , toString , toString , weight |
public void add(Term term)
Adds a term to the end of the query phrase. The relative position of the term is the one immediately after the last term added.
public void add(Term term, int position)
Adds a term to the end of the query phrase. The relative position of the term within the phrase is specified explicitly. This allows e.g. phrases with more than one term at the same position or phrases with gaps (e.g. in connection with stopwords).
- Parameters:
term
-position
-
protected Weight createWeight(Searcher searcher) throws IOException
Expert: Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries, which re-write to themselves.
- Overrides:
- createWeight in interface Query
public boolean equals(Object o)
Returns true iffo
is equal to this.
public void extractTerms(Set queryTerms)
- Overrides:
- extractTerms in interface Query
- See Also:
org.apache.lucene.search.Query.extractTerms(java.util.Set)
public int[] getPositions()
Returns the relative positions of terms in this phrase.
public int getSlop()
Returns the slop. See setSlop().
public int hashCode()
Returns a hash code value for this object.
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 aWITHIN
orNEAR
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.