Disjunction max Query
分离最大得分查询
Returns documents matching one or more wrapped queries, called query clauses or clauses.
返回的文档与一个或多个包装查询匹配,也称为查询子句或子句。
If a returned document matches multiple query clauses, the dis_max
query assigns the document the highest relevance score from any matching clause, plus a tie breaking increment for any additional matching subqueries.
如果返回的文档与多个查询子句匹配,则dis_max
查询会将所有匹配子句中最高的相关性得分,再加上其他匹配子查询的tie breaking增量作为最终的相关性得分赋予文档。
You can use the dis_max
to search for a term in fields mapped with different boost factors.
您可以使用dis_max
为字段中的term分配不同的boost因子 。
Example request
GET /_search
{
"query": {
"dis_max" : {
"queries" : [
{ "term" : { "title" : "Quick pets" }},
{ "term" : { "body" : "Quick pets" }}
],
"tie_breaker" : 0.7
}
}
}
Copy as cURLView in Console
Top-level parameters for dis_max
dis_max
的一级参数
-
queries
(Required, array of query objects) Contains one or more query clauses. Returned documents must match one or more of these queries. If a document matches multiple queries, Elasticsearch uses the highest relevance score.
(必需,查询对象数组)包含一个或多个查询子句。返回的文档必须与这些查询中的一个或多个匹配。如果一个文档匹配多个查询,Elasticsearch将使用最高的相关性得分。
-
tie_breaker
(Optional, float) Floating point number between
0
and1.0
used to increase the relevance scores of documents matching multiple query clauses. Defaults to0.0
.(可选,float)介于
0
和1.0
之间的浮点数,用于提升与多个查询子句匹配的文档的相关性得分。默认为0.0
。You can use the
tie_breaker
value to assign higher relevance scores to documents that contain the same term in multiple fields than documents that contain this term in only the best of those multiple fields, without confusing this with the better case of two different terms in the multiple fields.您可以使用
tie_breaker
值为多个字段中有多个匹配term的文档比多个字段中仅有一个最佳匹配term的文档分配更高的相关性得分。
不要与多个字段中两个不同term之间较好的情况混淆。If a document matches multiple clauses, the
dis_max
query calculates the relevance score for the document as follows:如果文档与多个子句匹配,
dis_max
查询将按照下面的方式计算文档的相关性得分:-
Take the relevance score from a matching clause with the highest score.
-
Multiply the score from any other matching clauses by the
tie_breaker
value. -
Add the highest score to the multiplied scores.
-
从具有最高分数的匹配子句中获取相关性分数。
-
将其他匹配子句的分数乘以该
tie_breaker
值。 -
将最高分数加到相乘的分数上。
If the
tie_breaker
value is greater than0.0
, all matching clauses count, but the clause with the highest score counts most.如果该
tie_breaker
值大于0.0
,会考虑所有匹配语句,但匹配语句中的最高得分会占最终结果的大头。 -