Package org.apache.lucene.queries
Class BoostingQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.queries.BoostingQuery
- All Implemented Interfaces:
Cloneable
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-userinvalid input: '&m'=108058407130459invalid input: '&w'=2
and is documented here: http://wiki.apache.org/lucene-java/CommunityContributions
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.lucene.search.Query
clone, createWeight, extractTerms, getBoost, setBoost, toString
-
Constructor Details
-
BoostingQuery
-
-
Method Details
-
rewrite
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.- Overrides:
rewrite
in classQuery
- Throws:
IOException
-
hashCode
public int hashCode() -
equals
-
toString
Description copied from class:Query
Prints a query to a string, withfield
assumed to be the default field and omitted.
-