public class BoostingQueryBuilder extends AbstractQueryBuilder<BoostingQueryBuilder>
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
Writeable.Reader<V>, Writeable.Writer<V>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
EMPTY_PARAMS
Constructor and Description |
---|
BoostingQueryBuilder(QueryBuilder positiveQuery,
QueryBuilder negativeQuery)
Create a new
BoostingQueryBuilder |
BoostingQueryBuilder(StreamInput in)
Read from a stream.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
doEquals(BoostingQueryBuilder other)
Indicates whether some other
QueryBuilder object of the same type is "equal to" this one. |
protected int |
doHashCode() |
protected QueryBuilder |
doRewrite(QueryRewriteContext queryRewriteContext) |
protected org.apache.lucene.search.Query |
doToQuery(QueryShardContext context) |
protected void |
doWriteTo(StreamOutput out) |
protected void |
doXContent(XContentBuilder builder,
ToXContent.Params params) |
protected void |
extractInnerHitBuilders(java.util.Map<java.lang.String,InnerHitContextBuilder> innerHits)
For internal usage only!
Extracts the inner hits from the query tree.
|
static java.util.Optional<BoostingQueryBuilder> |
fromXContent(QueryParseContext parseContext) |
java.lang.String |
getWriteableName()
Returns the name of the writeable object
|
float |
negativeBoost()
Get the negative boost factor.
|
BoostingQueryBuilder |
negativeBoost(float negativeBoost)
Set the negative boost factor.
|
QueryBuilder |
negativeQuery()
Get the negative query for this boosting query.
|
QueryBuilder |
positiveQuery()
Get the positive query for this boosting query.
|
addValidationError, boost, boost, convertToBytesRefIfString, convertToStringIfBytesRef, declareStandardFields, equals, getName, hashCode, printBoostAndQueryName, queryName, queryName, readQueries, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toFilter, toQueries, toQuery, toXContent, writeQueries, writeTo
buildAsBytes, buildAsBytes, toString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
rewriteQuery
isFragment
public static final java.lang.String NAME
public BoostingQueryBuilder(QueryBuilder positiveQuery, QueryBuilder negativeQuery)
BoostingQueryBuilder
positiveQuery
- the positive query for this boosting query.negativeQuery
- the negative query for this boosting query.public BoostingQueryBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
protected void doWriteTo(StreamOutput out) throws java.io.IOException
doWriteTo
in class AbstractQueryBuilder<BoostingQueryBuilder>
java.io.IOException
public QueryBuilder positiveQuery()
public QueryBuilder negativeQuery()
public BoostingQueryBuilder negativeBoost(float negativeBoost)
public float negativeBoost()
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
doXContent
in class AbstractQueryBuilder<BoostingQueryBuilder>
java.io.IOException
public static java.util.Optional<BoostingQueryBuilder> fromXContent(QueryParseContext parseContext) throws java.io.IOException
java.io.IOException
public java.lang.String getWriteableName()
NamedWriteable
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException
doToQuery
in class AbstractQueryBuilder<BoostingQueryBuilder>
java.io.IOException
protected int doHashCode()
doHashCode
in class AbstractQueryBuilder<BoostingQueryBuilder>
protected boolean doEquals(BoostingQueryBuilder other)
AbstractQueryBuilder
QueryBuilder
object of the same type is "equal to" this one.doEquals
in class AbstractQueryBuilder<BoostingQueryBuilder>
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws java.io.IOException
doRewrite
in class AbstractQueryBuilder<BoostingQueryBuilder>
java.io.IOException
protected void extractInnerHitBuilders(java.util.Map<java.lang.String,InnerHitContextBuilder> innerHits)
AbstractQueryBuilder
extractInnerHitBuilders
in class AbstractQueryBuilder<BoostingQueryBuilder>