Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class BoostingQuery

    The BoostingQuery class can be used to effectively demote results that match a given query. Unlike the "NOT" clause, this still selects documents that contain undesirable terms, but reduces their overall score:

    Query balancedQuery = new BoostingQuery(positiveQuery, negativeQuery, 0.01f);

    In this scenario the positiveQuery contains the mandatory, desirable criteria which is used to select all matching documents, and the negativeQuery contains the undesirable elements which are simply used to lessen the scores. Documents that match the negativeQuery have their score multiplied by the supplied "boost" parameter, so this should be less than 1 to achieve a demoting effect

    This code was originally made available here: [WWW] http://marc.theaimsgroup.com/?l=lucene-user&m=108058407130459&w=2 and is documented here: http://wiki.apache.org/lucene-java/CommunityContributions

    Inheritance
    object
    Query
    BoostingQuery
    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.Queries
    Assembly: Lucene.Net.Queries.dll
    Syntax
    public class BoostingQuery : Query

    Constructors

    BoostingQuery(Query, Query, float)

    The BoostingQuery class can be used to effectively demote results that match a given query. Unlike the "NOT" clause, this still selects documents that contain undesirable terms, but reduces their overall score:

    Query balancedQuery = new BoostingQuery(positiveQuery, negativeQuery, 0.01f);

    In this scenario the positiveQuery contains the mandatory, desirable criteria which is used to select all matching documents, and the negativeQuery contains the undesirable elements which are simply used to lessen the scores. Documents that match the negativeQuery have their score multiplied by the supplied "boost" parameter, so this should be less than 1 to achieve a demoting effect

    This code was originally made available here: [WWW] http://marc.theaimsgroup.com/?l=lucene-user&m=108058407130459&w=2 and is documented here: http://wiki.apache.org/lucene-java/CommunityContributions

    Declaration
    public BoostingQuery(Query match, Query context, float boost)
    Parameters
    Type Name Description
    Query match
    Query context
    float boost

    Methods

    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)

    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.