Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class FuzzyLikeThisQuery

    Fuzzifies ALL terms provided as strings and then picks the best n differentiating terms. In effect this mixes the behaviour of Lucene.Net.Search.FuzzyQuery and MoreLikeThis but with special consideration of fuzzy scoring factors. This generally produces good results for queries where users may provide details in a number of fields and have no knowledge of boolean query syntax and also want a degree of fuzzy matching and a fast query.

    For each source term the fuzzy variants are held in a Lucene.Net.Search.BooleanQuery with no coord factor (because we are not looking for matches on multiple variants in any one doc). Additionally, a specialized Lucene.Net.Search.TermQuery is used for variants and does not use that variant term's IDF because this would favour rarer terms eg misspellings. Instead, all variants use the same IDF ranking (the one for the source query term) and this is factored into the variant's boost. If the source query term does not exist in the index the average IDF of the variants is used.
    Inheritance
    object
    Query
    FuzzyLikeThisQuery
    Inherited Members
    Query.Boost
    Query.ToString()
    Query.CreateWeight(IndexSearcher)
    Query.ExtractTerms(ISet<Term>)
    Query.Clone()
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Sandbox.Queries
    Assembly: Lucene.Net.Sandbox.dll
    Syntax
    public class FuzzyLikeThisQuery : Query

    Constructors

    FuzzyLikeThisQuery(int, Analyzer)

    Fuzzifies ALL terms provided as strings and then picks the best n differentiating terms. In effect this mixes the behaviour of Lucene.Net.Search.FuzzyQuery and MoreLikeThis but with special consideration of fuzzy scoring factors. This generally produces good results for queries where users may provide details in a number of fields and have no knowledge of boolean query syntax and also want a degree of fuzzy matching and a fast query.

    For each source term the fuzzy variants are held in a Lucene.Net.Search.BooleanQuery with no coord factor (because we are not looking for matches on multiple variants in any one doc). Additionally, a specialized Lucene.Net.Search.TermQuery is used for variants and does not use that variant term's IDF because this would favour rarer terms eg misspellings. Instead, all variants use the same IDF ranking (the one for the source query term) and this is factored into the variant's boost. If the source query term does not exist in the index the average IDF of the variants is used.
    Declaration
    public FuzzyLikeThisQuery(int maxNumTerms, Analyzer analyzer)
    Parameters
    Type Name Description
    int maxNumTerms

    The total number of terms clauses that will appear once rewritten as a Lucene.Net.Search.BooleanQuery

    Analyzer analyzer

    Properties

    IgnoreTF

    Fuzzifies ALL terms provided as strings and then picks the best n differentiating terms. In effect this mixes the behaviour of Lucene.Net.Search.FuzzyQuery and MoreLikeThis but with special consideration of fuzzy scoring factors. This generally produces good results for queries where users may provide details in a number of fields and have no knowledge of boolean query syntax and also want a degree of fuzzy matching and a fast query.

    For each source term the fuzzy variants are held in a Lucene.Net.Search.BooleanQuery with no coord factor (because we are not looking for matches on multiple variants in any one doc). Additionally, a specialized Lucene.Net.Search.TermQuery is used for variants and does not use that variant term's IDF because this would favour rarer terms eg misspellings. Instead, all variants use the same IDF ranking (the one for the source query term) and this is factored into the variant's boost. If the source query term does not exist in the index the average IDF of the variants is used.
    Declaration
    public virtual bool IgnoreTF { get; set; }
    Property Value
    Type Description
    bool

    Methods

    AddTerms(string, string, float, int)

    Adds user input for "fuzzification"

    Declaration
    public virtual void AddTerms(string queryString, string fieldName, float minSimilarity, int prefixLength)
    Parameters
    Type Name Description
    string queryString

    The string which will be parsed by the analyzer and for which fuzzy variants will be parsed

    string fieldName

    The minimum similarity of the term variants (see Lucene.Net.Search.FuzzyTermsEnum)

    float minSimilarity

    Length of required common prefix on variant terms (see Lucene.Net.Search.FuzzyTermsEnum)

    int prefixLength

    Equals(object)

    Determines whether the specified object is equal to the current object.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with the current object.

    Returns
    Type Description
    bool

    true if the specified object is equal to the current object; otherwise, false.

    Overrides
    Query.Equals(object)

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current object.

    Overrides
    Lucene.Net.Search.Query.GetHashCode()

    Rewrite(IndexReader)

    Expert: called to re-write queries into primitive queries. For example, a Lucene.Net.Search.PrefixQuery will be rewritten into a Lucene.Net.Search.BooleanQuery that consists of Lucene.Net.Search.TermQuerys.

    Declaration
    public override Query Rewrite(IndexReader reader)
    Parameters
    Type Name Description
    IndexReader reader
    Returns
    Type Description
    Query
    Overrides
    Lucene.Net.Search.Query.Rewrite(Lucene.Net.Index.IndexReader)

    ToString(string)

    (non-Javadoc) ToString(string)

    Declaration
    public override string ToString(string field)
    Parameters
    Type Name Description
    string field
    Returns
    Type Description
    string
    Overrides
    Query.ToString(string)
    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.