public class

BoostingQuery

extends Query
java.lang.Object
   ↳ org.apache.lucene.search.Query
     ↳ org.apache.lucene.search.BoostingQuery

Class Overview

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

Summary

Public Constructors
BoostingQuery(Query match, Query context, float boost)
Public Methods
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.
[Expand]
Inherited Methods
From class org.apache.lucene.search.Query
From class java.lang.Object

Public Constructors

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

Public Methods

public boolean equals (Object obj)

public int hashCode ()

public Query rewrite (IndexReader reader)

Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.

Throws
IOException

public String toString (String field)

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:

  • If the query was created by the parser, the printed representation may not be exactly what was parsed. For example, characters that need to be escaped will be represented without the required backslash.
  • Some of the more complicated queries (e.g. span queries) don't have a representation that can be parsed by QueryParser.