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 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
-
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 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(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 DisMaxQueryBuilder
fromXContent(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, 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:
doWriteTo
in 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:
doXContent
in 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:
doToQuery
in classAbstractQueryBuilder<DisMaxQueryBuilder>
- Throws:
java.io.IOException
-
doRewrite
protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) throws java.io.IOException
- Overrides:
doRewrite
in classAbstractQueryBuilder<DisMaxQueryBuilder>
- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()
- Specified by:
doHashCode
in classAbstractQueryBuilder<DisMaxQueryBuilder>
-
doEquals
protected boolean doEquals(DisMaxQueryBuilder other)
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>
-
-