public class NGramPhraseQuery extends Query
PhraseQuery
which is optimized for n-gram phrase query.
For example, when you query "ABCD" on a 2-gram field, you may want to use
NGramPhraseQuery rather than PhraseQuery
, because NGramPhraseQuery
will rewrite(IndexReader)
the query to "AB/0 CD/2", while PhraseQuery
will query "AB/0 BC/1 CD/2" (where term/position).Constructor and Description |
---|
NGramPhraseQuery(int n,
PhraseQuery query)
Constructor that takes gram size.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
Override and implement query instance equivalence properly in a subclass.
|
int |
getN()
Return the n in n-gram
|
int[] |
getPositions()
Return the list of relative positions that each term should appear at.
|
Term[] |
getTerms()
Return the list of terms.
|
int |
hashCode()
Override and implement query hash code properly in a subclass.
|
Query |
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries.
|
String |
toString(String field)
Prints a query to a string, with
field assumed to be the
default field and omitted. |
void |
visit(QueryVisitor visitor)
Recurse through the query tree, visiting any child queries
|
classHash, createWeight, sameClassAs, toString
public NGramPhraseQuery(int n, PhraseQuery query)
n
- n-gram sizepublic Query rewrite(IndexReader reader) throws IOException
Query
Callers are expected to call rewrite
multiple times if necessary, until the
rewritten query is the same as the original query.
rewrite
in class Query
IOException
IndexSearcher.rewrite(Query)
public void visit(QueryVisitor visitor)
Query
public boolean equals(Object other)
Query
QueryCache
works properly.
Typically a query will be equal to another only if it's an instance of
the same class and its document-filtering properties are identical that other
instance. Utility methods are provided for certain repetitive code.equals
in class Query
Query.sameClassAs(Object)
,
Query.classHash()
public int hashCode()
Query
QueryCache
works properly.hashCode
in class Query
Query.equals(Object)
public int getN()
public Term[] getTerms()
public int[] getPositions()
Copyright © 2000-2022 Apache Software Foundation. All Rights Reserved.