Package org.apache.lucene.search
Class NGramPhraseQuery
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.lucene.search.PhraseQuery
-
- org.apache.lucene.search.NGramPhraseQuery
-
- All Implemented Interfaces:
Cloneable
public class NGramPhraseQuery extends PhraseQuery
This is aPhraseQuery
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 thanPhraseQuery
, because NGramPhraseQuery willrewrite(IndexReader)
the query to "AB/0 CD/2", whilePhraseQuery
will query "AB/0 BC/1 CD/2" (where term/position).
-
-
Constructor Summary
Constructors Constructor Description NGramPhraseQuery(int n)
Constructor that takes gram size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Returns true iffo
is equal to this.int
hashCode()
Returns a hash code value for this object.Query
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries.-
Methods inherited from class org.apache.lucene.search.PhraseQuery
add, add, createWeight, extractTerms, getPositions, getSlop, getTerms, setSlop, toString
-
-
-
-
Method Detail
-
rewrite
public Query rewrite(IndexReader reader) throws IOException
Description copied from class:Query
Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.- Overrides:
rewrite
in classPhraseQuery
- Throws:
IOException
-
equals
public boolean equals(Object o)
Returns true iffo
is equal to this.- Overrides:
equals
in classPhraseQuery
-
hashCode
public int hashCode()
Returns a hash code value for this object.- Overrides:
hashCode
in classPhraseQuery
-
-