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:QueryExpert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.- Overrides:
rewritein classPhraseQuery- Throws:
IOException
-
equals
Returns true iffois equal to this.- Overrides:
equalsin classPhraseQuery
-
hashCode
public int hashCode()Returns a hash code value for this object.- Overrides:
hashCodein classPhraseQuery
-