Package org.apache.lucene.search
Class MultiPhraseQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.MultiPhraseQuery
- All Implemented Interfaces:
Cloneable
MultiPhraseQuery is a generalized version of PhraseQuery, with an added
method
add(Term[]).
To use this class, to search for the phrase "Microsoft app*" first use
add(Term) on the term "Microsoft", then find all terms that have "app" as
prefix using IndexReader.terms(Term), and use MultiPhraseQuery.add(Term[]
terms) to add them to the query.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a single term at the next position in the phrase.voidAdd multiple terms at the next position in the phrase.voidAllows to specify the relative position of terms within the phrase.createWeight(IndexSearcher searcher) Expert: Constructs an appropriate Weight implementation for this query.booleanReturns true ifois equal to this.voidextractTerms(Set<Term> terms) Expert: adds all terms occurring in this query to the terms set.int[]Returns the relative positions of terms in this phrase.intgetSlop()Sets the phrase slop for this query.Returns a List of the terms in the multiphrase.inthashCode()Returns a hash code value for this object.rewrite(IndexReader reader) Expert: called to re-write queries into primitive queries.voidsetSlop(int s) Sets the phrase slop for this query.final StringPrints a user-readable version of this query.
-
Constructor Details
-
MultiPhraseQuery
public MultiPhraseQuery()
-
-
Method Details
-
setSlop
public void setSlop(int s) Sets the phrase slop for this query.- See Also:
-
getSlop
public int getSlop()Sets the phrase slop for this query.- See Also:
-
add
Add a single term at the next position in the phrase.- See Also:
-
add
Add multiple terms at the next position in the phrase. Any of the terms may match.- See Also:
-
add
Allows to specify the relative position of terms within the phrase.- See Also:
-
getTermArrays
Returns a List of the terms in the multiphrase. Do not modify the List or its contents. -
getPositions
public int[] getPositions()Returns the relative positions of terms in this phrase. -
extractTerms
Description copied from class:QueryExpert: adds all terms occurring in this query to the terms set. Only works if this query is in itsrewrittenform.- Overrides:
extractTermsin classQuery
-
rewrite
Description copied from class:QueryExpert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys. -
createWeight
Description copied from class:QueryExpert: Constructs an appropriate Weight implementation for this query.Only implemented by primitive queries, which re-write to themselves.
- Overrides:
createWeightin classQuery- Throws:
IOException
-
toString
Prints a user-readable version of this query. -
equals
Returns true ifois equal to this. -
hashCode
public int hashCode()Returns a hash code value for this object.
-