Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class ReciprocalSingleFunction

    ReciprocalSingleFunction implements a reciprocal function f(x) = a/(mx+b), based on the float value of a field or function as exported by ValueSource.

    When a and b are equal, and x>=0, this function has a maximum value of 1 that drops as x increases. Increasing the value of a and b together results in a movement of the entire function to a flatter part of the curve.

    These properties make this an idea function for boosting more recent documents.

    Example: recip(ms(NOW,mydatefield),3.16e-11,1,1)

    A multiplier of 3.16e-11 changes the units from milliseconds to years (since there are about 3.16e10 milliseconds per year). Thus, a very recent date will yield a value close to 1/(0+1) or 1, a date a year in the past will get a multiplier of about 1/(1+1) or 1/2, and date two years old will yield 1/(2+1) or 1/3.

    NOTE: This was ReciprocalFloatFunction in Lucene
    Inheritance
    object
    ValueSource
    ReciprocalSingleFunction
    Inherited Members
    ValueSource.ToString()
    ValueSource.NewContext(IndexSearcher)
    ValueSource.GetSortField(bool)
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Queries.Function.ValueSources
    Assembly: Lucene.Net.Queries.dll
    Syntax
    public class ReciprocalSingleFunction : ValueSource

    Constructors

    ReciprocalSingleFunction(ValueSource, float, float, float)

    f(source) = a/(m*float(source)+b)

    Declaration
    public ReciprocalSingleFunction(ValueSource source, float m, float a, float b)
    Parameters
    Type Name Description
    ValueSource source
    float m
    float a
    float b
    See Also
    FunctionQuery

    Fields

    m_a

    ReciprocalSingleFunction implements a reciprocal function f(x) = a/(mx+b), based on the float value of a field or function as exported by ValueSource.

    When a and b are equal, and x>=0, this function has a maximum value of 1 that drops as x increases. Increasing the value of a and b together results in a movement of the entire function to a flatter part of the curve.

    These properties make this an idea function for boosting more recent documents.

    Example: recip(ms(NOW,mydatefield),3.16e-11,1,1)

    A multiplier of 3.16e-11 changes the units from milliseconds to years (since there are about 3.16e10 milliseconds per year). Thus, a very recent date will yield a value close to 1/(0+1) or 1, a date a year in the past will get a multiplier of about 1/(1+1) or 1/2, and date two years old will yield 1/(2+1) or 1/3.

    NOTE: This was ReciprocalFloatFunction in Lucene
    Declaration
    protected readonly float m_a
    Field Value
    Type Description
    float
    See Also
    FunctionQuery

    m_b

    ReciprocalSingleFunction implements a reciprocal function f(x) = a/(mx+b), based on the float value of a field or function as exported by ValueSource.

    When a and b are equal, and x>=0, this function has a maximum value of 1 that drops as x increases. Increasing the value of a and b together results in a movement of the entire function to a flatter part of the curve.

    These properties make this an idea function for boosting more recent documents.

    Example: recip(ms(NOW,mydatefield),3.16e-11,1,1)

    A multiplier of 3.16e-11 changes the units from milliseconds to years (since there are about 3.16e10 milliseconds per year). Thus, a very recent date will yield a value close to 1/(0+1) or 1, a date a year in the past will get a multiplier of about 1/(1+1) or 1/2, and date two years old will yield 1/(2+1) or 1/3.

    NOTE: This was ReciprocalFloatFunction in Lucene
    Declaration
    protected readonly float m_b
    Field Value
    Type Description
    float
    See Also
    FunctionQuery

    m_m

    ReciprocalSingleFunction implements a reciprocal function f(x) = a/(mx+b), based on the float value of a field or function as exported by ValueSource.

    When a and b are equal, and x>=0, this function has a maximum value of 1 that drops as x increases. Increasing the value of a and b together results in a movement of the entire function to a flatter part of the curve.

    These properties make this an idea function for boosting more recent documents.

    Example: recip(ms(NOW,mydatefield),3.16e-11,1,1)

    A multiplier of 3.16e-11 changes the units from milliseconds to years (since there are about 3.16e10 milliseconds per year). Thus, a very recent date will yield a value close to 1/(0+1) or 1, a date a year in the past will get a multiplier of about 1/(1+1) or 1/2, and date two years old will yield 1/(2+1) or 1/3.

    NOTE: This was ReciprocalFloatFunction in Lucene
    Declaration
    protected readonly float m_m
    Field Value
    Type Description
    float
    See Also
    FunctionQuery

    m_source

    ReciprocalSingleFunction implements a reciprocal function f(x) = a/(mx+b), based on the float value of a field or function as exported by ValueSource.

    When a and b are equal, and x>=0, this function has a maximum value of 1 that drops as x increases. Increasing the value of a and b together results in a movement of the entire function to a flatter part of the curve.

    These properties make this an idea function for boosting more recent documents.

    Example: recip(ms(NOW,mydatefield),3.16e-11,1,1)

    A multiplier of 3.16e-11 changes the units from milliseconds to years (since there are about 3.16e10 milliseconds per year). Thus, a very recent date will yield a value close to 1/(0+1) or 1, a date a year in the past will get a multiplier of about 1/(1+1) or 1/2, and date two years old will yield 1/(2+1) or 1/3.

    NOTE: This was ReciprocalFloatFunction in Lucene
    Declaration
    protected readonly ValueSource m_source
    Field Value
    Type Description
    ValueSource
    See Also
    FunctionQuery

    Methods

    CreateWeight(IDictionary, IndexSearcher)

    Implementations should propagate CreateWeight to sub-ValueSources which can optionally store weight info in the context. The context object will be passed to GetValues() where this info can be retrieved.

    Declaration
    public override void CreateWeight(IDictionary context, IndexSearcher searcher)
    Parameters
    Type Name Description
    IDictionary context
    IndexSearcher searcher
    Overrides
    ValueSource.CreateWeight(IDictionary, IndexSearcher)
    See Also
    FunctionQuery

    Equals(object)

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

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

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

    Overrides
    ValueSource.Equals(object)
    See Also
    FunctionQuery

    GetDescription()

    description of field, used in Explain()

    Declaration
    public override string GetDescription()
    Returns
    Type Description
    string
    Overrides
    ValueSource.GetDescription()
    See Also
    FunctionQuery

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current object.

    Overrides
    ValueSource.GetHashCode()
    See Also
    FunctionQuery

    GetValues(IDictionary, AtomicReaderContext)

    Gets the values for this reader and the context that was previously passed to CreateWeight(IDictionary, IndexSearcher)

    Declaration
    public override FunctionValues GetValues(IDictionary context, AtomicReaderContext readerContext)
    Parameters
    Type Name Description
    IDictionary context
    AtomicReaderContext readerContext
    Returns
    Type Description
    FunctionValues
    Overrides
    ValueSource.GetValues(IDictionary, AtomicReaderContext)
    See Also
    FunctionQuery

    See Also

    FunctionQuery
    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.