Package org.elasticsearch.index.query
Class DisMaxQueryBuilder
- java.lang.Object
-
- org.elasticsearch.index.query.AbstractQueryBuilder<DisMaxQueryBuilder>
-
- org.elasticsearch.index.query.DisMaxQueryBuilder
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,QueryBuilder,Rewriteable<QueryBuilder>
public class DisMaxQueryBuilder extends AbstractQueryBuilder<DisMaxQueryBuilder>
A query that generates the union of documents produced by its sub-queries, and that scores each document with the maximum score for that document as produced by any sub-query, plus a tie breaking increment for any additional matching sub-queries.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
Fields Modifier and Type Field Description static floatDEFAULT_TIE_BREAKERDefault multiplication factor for breaking ties in document scores.static java.lang.StringNAME-
Fields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
-
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description DisMaxQueryBuilder()DisMaxQueryBuilder(StreamInput in)Read from a stream.
-
Method Summary
Modifier and Type Method Description DisMaxQueryBuilderadd(QueryBuilder queryBuilder)Add a sub-query to this disjunction.protected booleandoEquals(DisMaxQueryBuilder other)Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intdoHashCode()protected QueryBuilderdoRewrite(QueryRewriteContext queryShardContext)protected org.apache.lucene.search.QuerydoToQuery(QueryShardContext context)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(XContentBuilder builder, ToXContent.Params params)protected voidextractInnerHitBuilders(java.util.Map<java.lang.String,InnerHitContextBuilder> innerHits)For internal usage only! Extracts the inner hits from the query tree.static DisMaxQueryBuilderfromXContent(XContentParser parser)java.lang.StringgetWriteableName()Returns the name of the writeable objectjava.util.List<QueryBuilder>innerQueries()floattieBreaker()DisMaxQueryBuildertieBreaker(float tieBreaker)The score of each non-maximum disjunct for a document is multiplied by this weight and added into the final score.-
Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, equals, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toFilter, toQuery, toString, toString, toXContent, writeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
DEFAULT_TIE_BREAKER
public static final float DEFAULT_TIE_BREAKER
Default multiplication factor for breaking ties in document scores.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DisMaxQueryBuilder
public DisMaxQueryBuilder()
-
DisMaxQueryBuilder
public DisMaxQueryBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
doWriteTo
protected void doWriteTo(StreamOutput out) throws java.io.IOException
- Specified by:
doWriteToin classAbstractQueryBuilder<DisMaxQueryBuilder>- Throws:
java.io.IOException
-
add
public DisMaxQueryBuilder add(QueryBuilder queryBuilder)
Add a sub-query to this disjunction.
-
innerQueries
public java.util.List<QueryBuilder> innerQueries()
- Returns:
- an immutable list copy of the current sub-queries of this disjunction
-
tieBreaker
public DisMaxQueryBuilder tieBreaker(float tieBreaker)
The score of each non-maximum disjunct for a document is multiplied by this weight and added into the final score. If non-zero, the value should be small, on the order of 0.1, which says that 10 occurrences of word in a lower-scored field that is also in a higher scored field is just as good as a unique word in the lower scored field (i.e., one that is not in any higher scored field.
-
tieBreaker
public float tieBreaker()
- Returns:
- the tie breaker score
- See Also:
tieBreaker(float)
-
doXContent
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
doXContentin classAbstractQueryBuilder<DisMaxQueryBuilder>- Throws:
java.io.IOException
-
fromXContent
public static DisMaxQueryBuilder fromXContent(XContentParser parser) throws java.io.IOException
- Throws:
java.io.IOException
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException
- Specified by:
doToQueryin classAbstractQueryBuilder<DisMaxQueryBuilder>- Throws:
java.io.IOException
-
doRewrite
protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws java.io.IOException
- Overrides:
doRewritein classAbstractQueryBuilder<DisMaxQueryBuilder>- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()
- Specified by:
doHashCodein classAbstractQueryBuilder<DisMaxQueryBuilder>
-
doEquals
protected boolean doEquals(DisMaxQueryBuilder other)
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<DisMaxQueryBuilder>
-
getWriteableName
public java.lang.String getWriteableName()
Description copied from interface:NamedWriteableReturns the name of the writeable object
-
extractInnerHitBuilders
protected void extractInnerHitBuilders(java.util.Map<java.lang.String,InnerHitContextBuilder> innerHits)
Description copied from class:AbstractQueryBuilderFor internal usage only! Extracts the inner hits from the query tree. While it extracts inner hits, child inner hits are inlined into the inner hit builder they belong to.- Overrides:
extractInnerHitBuildersin classAbstractQueryBuilder<DisMaxQueryBuilder>
-
-