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>
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.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic floatDefault multiplication factor for breaking ties in document scores.static StringFields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryNameFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(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 intprotected QueryBuilderdoRewrite(QueryRewriteContext queryRewriteContext)protected org.apache.lucene.search.QuerydoToQuery(SearchExecutionContext context)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)protected voidextractInnerHitBuilders(Map<String,InnerHitContextBuilder> innerHits)For internal usage only! Extracts the inner hits from the query tree.static DisMaxQueryBuilderfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)Returns the name of the writeable objectfloattieBreaker(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, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
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:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classAbstractQueryBuilder<DisMaxQueryBuilder>- Throws:
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 IOException- Specified by:
doXContentin classAbstractQueryBuilder<DisMaxQueryBuilder>- Throws:
IOException
-
fromXContent
public static DisMaxQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException- Throws:
IOException
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(SearchExecutionContext context) throws IOException- Specified by:
doToQueryin classAbstractQueryBuilder<DisMaxQueryBuilder>- Throws:
IOException
-
doRewrite
- Overrides:
doRewritein classAbstractQueryBuilder<DisMaxQueryBuilder>- Throws:
IOException
-
doHashCode
protected int doHashCode()- Specified by:
doHashCodein classAbstractQueryBuilder<DisMaxQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<DisMaxQueryBuilder>
-
getWriteableName
Description copied from interface:NamedWriteableReturns the name of the writeable object -
extractInnerHitBuilders
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>
-