Class NGramPhraseQuery
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).
Collection initializer note: To create and populate a PhraseQuery in a single statement, you can use the following example as a guide:var phraseQuery = new NGramPhraseQuery(2) {
new Term("field", "ABCD"),
new Term("field", "EFGH")
};
Note that as long as you specify all of the parameters, you can use either Add(Term) or Add(Term, int) as the method to use to initialize. If there are multiple parameters, each parameter set must be surrounded by curly braces.
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class NGramPhraseQuery : PhraseQuery, IEnumerable<Term>, IEnumerable
Constructors
NGramPhraseQuery(int)
Constructor that takes gram size.
Declaration
public NGramPhraseQuery(int n)
Parameters
Type | Name | Description |
---|---|---|
int | n | n-gram size |
Methods
Equals(object)
Returns true
if o
is equal to this.
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o |
Returns
Type | Description |
---|---|
bool |
Overrides
GetHashCode()
Returns a hash code value for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
Rewrite(IndexReader)
Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
Declaration
public override Query Rewrite(IndexReader reader)
Parameters
Type | Name | Description |
---|---|---|
IndexReader | reader |
Returns
Type | Description |
---|---|
Query |