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
|
(package private) static class |
MultiPhraseQuery.PostingsAndPosition |
(package private) static class |
MultiPhraseQuery.UnionFullPostingsEnum |
(package private) static class |
MultiPhraseQuery.UnionPostingsEnum
Takes the logical union of multiple PostingsEnum iterators.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
field |
private int[] |
positions |
private int |
slop |
private Term[][] |
termArrays |
Modifier | Constructor and Description |
---|---|
private |
MultiPhraseQuery(java.lang.String field,
Term[][] termArrays,
int[] positions,
int slop) |
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(java.lang.Object other)
Returns true if
o is equal to this. |
private boolean |
equalsTo(MultiPhraseQuery other) |
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.
|
private boolean |
termArraysEquals(Term[][] termArrays1,
Term[][] termArrays2) |
private int |
termArraysHashCode() |
java.lang.String |
toString(java.lang.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
private final java.lang.String field
private final Term[][] termArrays
private final int[] positions
private final int slop
private MultiPhraseQuery(java.lang.String field, Term[][] termArrays, int[] positions, int slop)
public int getSlop()
PhraseQuery.getSlop()
public Term[][] getTermArrays()
public int[] getPositions()
public Query rewrite(IndexReader reader) throws java.io.IOException
Query
public void visit(QueryVisitor visitor)
Query
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws java.io.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.java.io.IOException
public final java.lang.String toString(java.lang.String f)
public boolean equals(java.lang.Object other)
o
is equal to this.equals
in class Query
Query.sameClassAs(Object)
,
Query.classHash()
private boolean equalsTo(MultiPhraseQuery other)
public int hashCode()
hashCode
in class Query
Query.equals(Object)
private int termArraysHashCode()