Fork me on GitHub
  • API

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    Query
    PhraseQuery
    NGramPhraseQuery
    Implements
    IEnumerable<Term>
    IEnumerable
    Inherited Members
    PhraseQuery.Slop
    PhraseQuery.Add(Term)
    PhraseQuery.Add(Term, int)
    PhraseQuery.GetTerms()
    PhraseQuery.GetPositions()
    PhraseQuery.CreateWeight(IndexSearcher)
    PhraseQuery.ExtractTerms(ISet<Term>)
    PhraseQuery.ToString(string)
    PhraseQuery.GetEnumerator()
    Query.Boost
    Query.ToString()
    Query.Clone()
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    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
    PhraseQuery.Equals(object)

    GetHashCode()

    Returns a hash code value for this object.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    PhraseQuery.GetHashCode()

    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
    Overrides
    PhraseQuery.Rewrite(IndexReader)

    Implements

    IEnumerable<T>
    IEnumerable
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.