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.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic float
Default multiplication factor for breaking ties in document scores.static String
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
-
Method Summary
Modifier and TypeMethodDescriptionadd(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
protected QueryBuilder
doRewrite(QueryRewriteContext queryRewriteContext)
protected org.apache.lucene.search.Query
doToQuery(SearchExecutionContext 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(Map<String,InnerHitContextBuilder> innerHits)
For internal usage only! Extracts the inner hits from the query tree.static DisMaxQueryBuilder
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
Returns the name of the writeable objectfloat
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, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, 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 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:
doWriteTo
in 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:
doXContent
in 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:
doToQuery
in classAbstractQueryBuilder<DisMaxQueryBuilder>
- Throws:
IOException
-
doRewrite
- Overrides:
doRewrite
in classAbstractQueryBuilder<DisMaxQueryBuilder>
- Throws:
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
Description copied from interface:NamedWriteable
Returns the name of the writeable object -
extractInnerHitBuilders
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>
-