Class BoostingQuery

  extended by
      extended by
All Implemented Interfaces:
Serializable, Cloneable

public class BoostingQuery
extends Query

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] and is documented here:

See Also:
Serialized Form

Constructor Summary
BoostingQuery(Query match, Query context, float boost)
Method Summary
 boolean equals(Object obj)
 int hashCode()
 Query rewrite(IndexReader reader)
          Expert: called to re-write queries into primitive queries.
 String toString(String field)
          Prints a query to a string, with field assumed to be the default field and omitted.
Methods inherited from class
clone, combine, createWeight, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait

Constructor Detail


public BoostingQuery(Query match,
                     Query context,
                     float boost)
Method Detail


public Query rewrite(IndexReader reader)
              throws IOException
Description copied from class: Query
Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.

rewrite in class Query


public int hashCode()
hashCode in class Query


public boolean equals(Object obj)
equals in class Query


public String toString(String field)
Description copied from class: Query
Prints a query to a string, with field assumed to be the default field and omitted.

The representation used is one that is supposed to be readable by QueryParser. However, there are the following limitations:

Specified by:
toString in class Query

Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.