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, Int32) as the method to use to initialize. If there are multiple parameters, each parameter set must be surrounded by curly braces.
Implements
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class NGramPhraseQuery : PhraseQuery, IEnumerable<Term>
Constructors
| Improve this Doc View SourceNGramPhraseQuery(Int32)
Constructor that takes gram size.
Declaration
public NGramPhraseQuery(int n)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | n | n-gram size |
Methods
| Improve this Doc View SourceEquals(Object)
Returns true
if o
is equal to this.
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
| Improve this Doc View SourceGetHashCode()
Returns a hash code value for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
| Improve this Doc View SourceRewrite(IndexReader)
Declaration
public override Query Rewrite(IndexReader reader)
Parameters
Type | Name | Description |
---|---|---|
IndexReader | reader |
Returns
Type | Description |
---|---|
Query |