Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class CustomScoreQuery

    Query that sets document score as a programmatic function of several (sub) scores:

    • the score of its subQuery (any query)
    • (optional) the score of its FunctionQuery (or queries).
    Subclasses can modify the computation by overriding GetCustomScoreProvider(AtomicReaderContext).

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Inheritance
    object
    Query
    CustomScoreQuery
    Inherited Members
    Query.Boost
    Query.ToString()
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Queries
    Assembly: Lucene.Net.Queries.dll
    Syntax
    public class CustomScoreQuery : Query

    Constructors

    CustomScoreQuery(Query)

    Create a CustomScoreQuery over input subQuery.

    Declaration
    public CustomScoreQuery(Query subQuery)
    Parameters
    Type Name Description
    Query subQuery

    the sub query whose scored is being customized. Must not be null.

    CustomScoreQuery(Query, FunctionQuery)

    Create a CustomScoreQuery over input subQuery and a FunctionQuery.

    Declaration
    public CustomScoreQuery(Query subQuery, FunctionQuery scoringQuery)
    Parameters
    Type Name Description
    Query subQuery

    the sub query whose score is being customized. Must not be null.

    FunctionQuery scoringQuery

    a value source query whose scores are used in the custom score computation. This parameter is optional - it can be null.

    CustomScoreQuery(Query, params FunctionQuery[])

    Create a CustomScoreQuery over input subQuery and a FunctionQuery.

    Declaration
    public CustomScoreQuery(Query subQuery, params FunctionQuery[] scoringQueries)
    Parameters
    Type Name Description
    Query subQuery

    the sub query whose score is being customized. Must not be null.

    FunctionQuery[] scoringQueries

    value source queries whose scores are used in the custom score computation. This parameter is optional - it can be null or even an empty array.

    Properties

    IsStrict

    Checks if this is strict custom scoring. In strict custom scoring, the ValueSource part does not participate in weight normalization. This may be useful when one wants full control over how scores are modified, and does not care about normalizing by the ValueSource part. One particular case where this is useful if for testing this query.

    Note: only has effect when the ValueSource part is not null.
    Declaration
    public virtual bool IsStrict { get; set; }
    Property Value
    Type Description
    bool

    Name

    A short name of this query, used in ToString(string).

    Declaration
    public virtual string Name { get; }
    Property Value
    Type Description
    string

    ScoringQueries

    The scoring queries that only affect the score of CustomScoreQuery.

    Declaration
    public virtual Query[] ScoringQueries { get; }
    Property Value
    Type Description
    Query[]

    SubQuery

    The sub-query that CustomScoreQuery wraps, affecting both the score and which documents match.

    Declaration
    public virtual Query SubQuery { get; }
    Property Value
    Type Description
    Query

    Methods

    Clone()

    Lucene.Net.Search.Query.Clone()

    Declaration
    public override object Clone()
    Returns
    Type Description
    object
    Overrides
    Lucene.Net.Search.Query.Clone()

    CreateWeight(IndexSearcher)

    Expert: Constructs an appropriate Lucene.Net.Search.Weight implementation for this query.

    Only implemented by primitive queries, which re-write to themselves.
    Declaration
    public override Weight CreateWeight(IndexSearcher searcher)
    Parameters
    Type Name Description
    IndexSearcher searcher
    Returns
    Type Description
    Weight
    Overrides
    Lucene.Net.Search.Query.CreateWeight(Lucene.Net.Search.IndexSearcher)

    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
    Query.Equals(object)

    ExtractTerms(ISet<Term>)

    ExtractTerms(ISet<Term>)

    Declaration
    public override void ExtractTerms(ISet<Term> terms)
    Parameters
    Type Name Description
    ISet<Term> terms
    Overrides
    Query.ExtractTerms(ISet<Term>)

    GetCustomScoreProvider(AtomicReaderContext)

    Returns a CustomScoreProvider that calculates the custom scores for the given Lucene.Net.Index.IndexReader. The default implementation returns a default implementation as specified in the docs of CustomScoreProvider. @since 2.9.2

    Declaration
    protected virtual CustomScoreProvider GetCustomScoreProvider(AtomicReaderContext context)
    Parameters
    Type Name Description
    AtomicReaderContext context
    Returns
    Type Description
    CustomScoreProvider

    GetHashCode()

    Returns a hash code value for this object.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    Lucene.Net.Search.Query.GetHashCode()

    Rewrite(IndexReader)

    Lucene.Net.Search.Query.Rewrite(Lucene.Net.Index.IndexReader)

    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)

    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.