public class MultiPhraseQuery extends Query
PhraseQuery
, with the possibility of
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 create a Builder and use
MultiPhraseQuery.Builder.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 MultiPhraseQuery.Builder.add(Term[])
to add them.
MultiPhraseQuery.Builder.build()
returns the fully constructed (and immutable) MultiPhraseQuery.Modifier and Type | Class and Description |
---|---|
static class |
MultiPhraseQuery.Builder
A builder for multi-phrase queries
|
Modifier and Type | Method and Description |
---|---|
Weight |
createWeight(IndexSearcher searcher,
ScoreMode scoreMode,
float boost)
Expert: Constructs an appropriate Weight implementation for this query.
|
boolean |
equals(Object other)
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.
|
Term[][] |
getTermArrays()
Returns the arrays of arrays of 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.
|
String |
toString(String f)
Prints a user-readable version of this query.
|
void |
visit(QueryVisitor visitor)
Recurse through the query tree, visiting any child queries
|
classHash, sameClassAs, toString
public int getSlop()
PhraseQuery.getSlop()
public Term[][] getTermArrays()
public int[] getPositions()
public Query rewrite(IndexReader reader) throws IOException
Query
rewrite
in class Query
IOException
public void visit(QueryVisitor visitor)
Query
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
scoreMode
- How the produced scorers will be consumed.boost
- The boost that is propagated by the parent queries.IOException
public boolean equals(Object other)
o
is equal to this.equals
in class Query
Query.sameClassAs(Object)
,
Query.classHash()
public int hashCode()
hashCode
in class Query
Query.equals(Object)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.