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
This is a
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 Summary
Constructors -
Method Summary
Methods inherited from class org.apache.lucene.search.PhraseQuery
add, add, createWeight, extractTerms, getPositions, getSlop, getTerms, setSlop, toString
-
Constructor Details
-
NGramPhraseQuery
public NGramPhraseQuery(int n) Constructor that takes gram size.- Parameters:
n
- n-gram size
-
-
Method Details
-
rewrite
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
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
-