public class MultiPhraseQuery extends Query
PhraseQuery
, with an added
method add(Term[])
for adding more than one term at the same position
that are treated as a disjunction (OR).
To use this class to search for the phrase "Microsoft app*" first use
add(Term)
on the term "microsoft" (assuming lowercase analysis), then
find all terms that have "app" as prefix using LeafReader.terms(String)
,
seeking to "app" then iterating and collecting terms until there is no longer
that prefix, and finally use add(Term[])
to add them to the query.Constructor and Description |
---|
MultiPhraseQuery() |
Modifier and Type | Method and Description |
---|---|
void |
add(Term term)
Add a single term at the next position in the phrase.
|
void |
add(Term[] terms)
Add multiple terms at the next position in the phrase.
|
void |
add(Term[] terms,
int position)
Allows to specify the relative position of terms within the phrase.
|
Weight |
createWeight(IndexSearcher searcher,
boolean needsScores)
Expert: Constructs an appropriate Weight implementation for this query.
|
boolean |
equals(Object o)
Returns true if
o is equal to this. |
int[] |
getPositions()
Returns the relative positions of terms in this phrase.
|
int |
getSlop()
Sets the phrase slop for this query.
|
List<Term[]> |
getTermArrays()
Returns a List of the terms in the multi-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 phrase slop for this query.
|
String |
toString(String f)
Prints a user-readable version of this query.
|
public void setSlop(int s)
PhraseQuery.getSlop()
public int getSlop()
PhraseQuery.getSlop()
public void add(Term term)
public void add(Term[] terms)
public void add(Term[] terms, int position)
public List<Term[]> getTermArrays()
public int[] getPositions()
public Query rewrite(IndexReader reader) throws IOException
Query
rewrite
in class Query
IOException
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
needsScores
- True if document scores (Scorer.score()
) or match
frequencies (Scorer.freq()
) are needed.IOException
public boolean equals(Object o)
o
is equal to this.Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.