Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class ConstantScoreQuery

    A query that wraps another query or a filter and simply returns a constant score equal to the query boost for every document that matches the filter or query. For queries it therefore simply strips of all scores and returns a constant one.

    Inheritance
    object
    Query
    ConstantScoreQuery
    Inherited Members
    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 ConstantScoreQuery : Query

    Constructors

    ConstantScoreQuery(Filter)

    Wraps a Filter as a Query. The hits will get a constant score dependent on the boost factor of this query. If you simply want to strip off scores from a Query, no longer use new ConstantScoreQuery(new QueryWrapperFilter(query)), instead use ConstantScoreQuery(Query)!

    Declaration
    public ConstantScoreQuery(Filter filter)
    Parameters
    Type Name Description
    Filter filter
    Exceptions
    Type Condition
    ArgumentNullException

    if filter is null.

    ConstantScoreQuery(Query)

    Strips off scores from the passed in Query. The hits will get a constant score dependent on the boost factor of this query.

    Declaration
    public ConstantScoreQuery(Query query)
    Parameters
    Type Name Description
    Query query
    Exceptions
    Type Condition
    ArgumentNullException

    if query is null.

    Fields

    m_filter

    A query that wraps another query or a filter and simply returns a constant score equal to the query boost for every document that matches the filter or query. For queries it therefore simply strips of all scores and returns a constant one.

    Declaration
    protected readonly Filter m_filter
    Field Value
    Type Description
    Filter

    m_query

    A query that wraps another query or a filter and simply returns a constant score equal to the query boost for every document that matches the filter or query. For queries it therefore simply strips of all scores and returns a constant one.

    Declaration
    protected readonly Query m_query
    Field Value
    Type Description
    Query

    Properties

    Filter

    Returns the encapsulated filter, returns null if a query is wrapped.

    Declaration
    public virtual Filter Filter { get; }
    Property Value
    Type Description
    Filter

    Query

    Returns the encapsulated query, returns null if a filter is wrapped.

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

    Methods

    CreateWeight(IndexSearcher)

    Expert: Constructs an appropriate 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
    Query.CreateWeight(IndexSearcher)

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

    ExtractTerms(ISet<Term>)

    Expert: adds all terms occurring in this query to the terms set. Only works if this query is in its rewritten (Rewrite(IndexReader)) form.

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

    If this query is not yet rewritten

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current object.

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

    ToString(string)

    Prints a query to a string, with field assumed to be the default field and omitted.

    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.