Show / Hide Table of Contents

    Class PhraseQuery

    A Query that matches documents containing a particular sequence of terms. A PhraseQuery is built by QueryParser for input like "new york".

    This query may be combined with other terms or queries with a BooleanQuery.

    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 PhraseQuery() {
        new Term("field", "microsoft"), 
        new Term("field", "office")
    };

    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.

    Inheritance
    System.Object
    Query
    PhraseQuery
    NGramPhraseQuery
    Implements
    IEnumerable<Term>
    Inherited Members
    Query.Boost
    Query.ToString()
    Query.Clone()
    Namespace: Lucene.Net.Search
    Assembly: Lucene.Net.dll
    Syntax
    public class PhraseQuery : Query, IEnumerable<Term>

    Constructors

    | Improve this Doc View Source

    PhraseQuery()

    Constructs an empty phrase query.

    Declaration
    public PhraseQuery()

    Properties

    | Improve this Doc View Source

    Slop

    Sets the number of other words permitted between words in query phrase. If zero, then this is an exact phrase search. For larger values this works like a WITHIN or NEAR operator.

    The slop is in fact an edit-distance, where the units correspond to moves of terms in the query phrase out of position. For example, to switch the order of two words requires two moves (the first move places the words atop one another), so to permit re-orderings of phrases, the slop must be at least two.

    More exact matches are scored higher than sloppier matches, thus search results are sorted by exactness.

    The slop is zero by default, requiring exact matches.

    Declaration
    public virtual int Slop { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    Add(Term)

    Adds a term to the end of the query phrase. The relative position of the term is the one immediately after the last term added.

    Declaration
    public virtual void Add(Term term)
    Parameters
    Type Name Description
    Term term
    | Improve this Doc View Source

    Add(Term, Int32)

    Adds a term to the end of the query phrase. The relative position of the term within the phrase is specified explicitly. this allows e.g. phrases with more than one term at the same position or phrases with gaps (e.g. in connection with stopwords).

    Declaration
    public virtual void Add(Term term, int position)
    Parameters
    Type Name Description
    Term term
    System.Int32 position
    | Improve this Doc View Source

    CreateWeight(IndexSearcher)

    Declaration
    public override Weight CreateWeight(IndexSearcher searcher)
    Parameters
    Type Name Description
    IndexSearcher searcher
    Returns
    Type Description
    Weight
    Overrides
    Query.CreateWeight(IndexSearcher)
    | Improve this Doc View Source

    Equals(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
    Query.Equals(Object)
    | Improve this Doc View Source

    ExtractTerms(ISet<Term>)

    Declaration
    public override void ExtractTerms(ISet<Term> queryTerms)
    Parameters
    Type Name Description
    ISet<Term> queryTerms
    Overrides
    Query.ExtractTerms(ISet<Term>)
    See Also
    ExtractTerms(ISet<Term>)
    | Improve this Doc View Source

    GetEnumerator()

    Returns an enumerator that iterates through the Lucene.Net.Search.PhraseQuery.terms collection.

    Declaration
    public IEnumerator<Term> GetEnumerator()
    Returns
    Type Description
    IEnumerator<Term>

    An enumerator that can be used to iterate through the Lucene.Net.Search.PhraseQuery.terms collection.

    | Improve this Doc View Source

    GetHashCode()

    Returns a hash code value for this object.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    Query.GetHashCode()
    | Improve this Doc View Source

    GetPositions()

    Returns the relative positions of terms in this phrase.

    Declaration
    public virtual int[] GetPositions()
    Returns
    Type Description
    System.Int32[]
    | Improve this Doc View Source

    GetTerms()

    Returns the set of terms in this phrase.

    Declaration
    public virtual Term[] GetTerms()
    Returns
    Type Description
    Term[]
    | Improve this Doc View Source

    Rewrite(IndexReader)

    Declaration
    public override Query Rewrite(IndexReader reader)
    Parameters
    Type Name Description
    IndexReader reader
    Returns
    Type Description
    Query
    Overrides
    Query.Rewrite(IndexReader)
    | Improve this Doc View Source

    ToString(String)

    Prints a user-readable version of this query.

    Declaration
    public override string ToString(string f)
    Parameters
    Type Name Description
    System.String f
    Returns
    Type Description
    System.String
    Overrides
    Query.ToString(String)

    Implements

    IEnumerable<>
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)