public class PhraseQuery extends Query
"new york"
.
This query may be combined with other terms or queries with a BooleanQuery
.
Constructor and Description |
---|
PhraseQuery()
Constructs an empty phrase query.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Term term)
Adds a term to the end of the query phrase.
|
void |
add(Term term,
int position)
Adds a term to the end of the query phrase.
|
Weight |
createWeight(IndexSearcher searcher)
Expert: Constructs an appropriate Weight implementation for this query.
|
boolean |
equals(Object o)
Returns true iff
o is equal to this. |
void |
extractTerms(Set<Term> queryTerms)
Expert: adds all terms occurring in this query to the terms set.
|
int[] |
getPositions()
Returns the relative positions of terms in this phrase.
|
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.
|
Query |
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries.
|
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.
|
public void setSlop(int s)
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.
public int getSlop()
public void add(Term term)
public void add(Term term, int position)
public Term[] getTerms()
public int[] getPositions()
public Query rewrite(IndexReader reader) throws IOException
Query
rewrite
in class Query
IOException
public Weight createWeight(IndexSearcher searcher) throws IOException
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
IOException
public void extractTerms(Set<Term> queryTerms)
Query
rewritten
form.extractTerms
in class Query
Query.extractTerms(Set)
public boolean equals(Object o)
o
is equal to this.Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.