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
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.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
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.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 float
DEFAULT_TIE_BREAKER
Default multiplication factor for breaking ties in document scores.static java.lang.String
NAME
Fields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
-
Constructor Summary
Constructors Constructor Description DisMaxQueryBuilder()
DisMaxQueryBuilder(StreamInput in)
Read from a stream. -
Method Summary
Modifier and Type Method Description DisMaxQueryBuilder
add(QueryBuilder queryBuilder)
Add a sub-query to this disjunction.protected boolean
doEquals(DisMaxQueryBuilder other)
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.protected int
doHashCode()
protected QueryBuilder
doRewrite(QueryRewriteContext queryShardContext)
protected org.apache.lucene.search.Query
doToQuery(QueryShardContext context)
protected void
doWriteTo(StreamOutput out)
protected void
doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.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 DisMaxQueryBuilder
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
java.lang.String
getWriteableName()
Returns the name of the writeable objectjava.util.List<QueryBuilder>
innerQueries()
float
tieBreaker()
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.Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, equals, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeTo
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
DEFAULT_TIE_BREAKER
public static final float DEFAULT_TIE_BREAKERDefault multiplication factor for breaking ties in document scores.- See Also:
- Constant Field Values
-
-
Constructor Details
-
DisMaxQueryBuilder
public DisMaxQueryBuilder() -
DisMaxQueryBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteTo
in classAbstractQueryBuilder<DisMaxQueryBuilder>
- Throws:
java.io.IOException
-
add
Add a sub-query to this disjunction. -
innerQueries
- Returns:
- an immutable list copy of the current sub-queries of this disjunction
-
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(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
doXContent
in classAbstractQueryBuilder<DisMaxQueryBuilder>
- Throws:
java.io.IOException
-
fromXContent
public static DisMaxQueryBuilder fromXContent(org.elasticsearch.common.xcontent.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:
doToQuery
in classAbstractQueryBuilder<DisMaxQueryBuilder>
- Throws:
java.io.IOException
-
doRewrite
- Overrides:
doRewrite
in classAbstractQueryBuilder<DisMaxQueryBuilder>
- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()- Specified by:
doHashCode
in classAbstractQueryBuilder<DisMaxQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilder
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.- Specified by:
doEquals
in classAbstractQueryBuilder<DisMaxQueryBuilder>
-
getWriteableName
public java.lang.String getWriteableName()Description copied from interface:NamedWriteable
Returns the name of the writeable object -
extractInnerHitBuilders
protected void extractInnerHitBuilders(java.util.Map<java.lang.String,InnerHitContextBuilder> innerHits)Description copied from class:AbstractQueryBuilder
For 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:
extractInnerHitBuilders
in classAbstractQueryBuilder<DisMaxQueryBuilder>
-