org.elasticsearch.index.query
Class BoostingQueryBuilder

java.lang.Object
  extended by org.elasticsearch.index.query.BaseQueryBuilder
      extended by org.elasticsearch.index.query.BoostingQueryBuilder
All Implemented Interfaces:
ToXContent, BoostableQueryBuilder<BoostingQueryBuilder>, QueryBuilder

public class BoostingQueryBuilder
extends BaseQueryBuilder
implements BoostableQueryBuilder<BoostingQueryBuilder>

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


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.MapParams, ToXContent.Params
 
Field Summary
 
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
 
Constructor Summary
BoostingQueryBuilder()
           
 
Method Summary
 BoostingQueryBuilder boost(float boost)
          Sets the boost for this query.
protected  void doXContent(XContentBuilder builder, ToXContent.Params params)
           
 BoostingQueryBuilder negative(QueryBuilder negativeQuery)
           
 BoostingQueryBuilder negativeBoost(float negativeBoost)
           
 BoostingQueryBuilder positive(QueryBuilder positiveQuery)
           
 
Methods inherited from class org.elasticsearch.index.query.BaseQueryBuilder
buildAsBytes, buildAsBytes, toString, toXContent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoostingQueryBuilder

public BoostingQueryBuilder()
Method Detail

positive

public BoostingQueryBuilder positive(QueryBuilder positiveQuery)

negative

public BoostingQueryBuilder negative(QueryBuilder negativeQuery)

negativeBoost

public BoostingQueryBuilder negativeBoost(float negativeBoost)

boost

public BoostingQueryBuilder boost(float boost)
Description copied from interface: BoostableQueryBuilder
Sets the boost for this query. Documents matching this query will (in addition to the normal weightings) have their score multiplied by the boost provided.

Specified by:
boost in interface BoostableQueryBuilder<BoostingQueryBuilder>

doXContent

protected void doXContent(XContentBuilder builder,
                          ToXContent.Params params)
                   throws IOException
Specified by:
doXContent in class BaseQueryBuilder
Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.