Query DSL - Boosting Query

Boosting Query

Returns documents matching a positive query while reducing the relevance score of documents that also match a negative query.

可以为返回的文档匹配一个positive查询和一个negative查询,positive查询对文档的相关性得分没有影响,而negative查询会降低文档的 相关性得分

You can use the boosting query to demote certain documents without excluding them from the search results.

您可以使用boosting查询使某些文档降级,而不必将它们从搜索结果中排除。

Example request

GET /_search
{
    "query": {
        "boosting" : {
            "positive" : {
                "term" : {
                    "text" : "apple"
                }
            },
            "negative" : {
                 "term" : {
                     "text" : "pie tart fruit crumble tree"
                }
            },
            "negative_boost" : 0.5
        }
    }
}

Copy as cURLView in Console

Top-level parameters for boosting

boosting的一级参数

  • positive

    (Required, query object) Query you wish to run. Any returned documents must match this query.

    (必需,查询对象)您希望运行的查询。任何返回的文档都必须与此查询匹配。

  • negative

    (Required, query object) Query used to decrease the relevance score of matching documents.If a returned document matches the positive query and this query, the boosting query calculates the final relevance score for the document as follows:Take the original relevance score from the positive query.Multiply the score by the negative_boost value.

    (必需,查询对象)查询用来降低匹配文档的相关性得分。如果返回的文档匹配positive查询和此查询,则该 boosting查询将按如下方式计算该文档的最终相关性得分:从positive查询中获取原始的相关性分数,再将分数乘以negative_boost值。

  • negative_boost

    (Required, float) Floating point number between 0 and 1.0 used to decrease the relevance scores of documents matching the negative query.

    (必需,浮点数)介于01.0之间的浮点数,用于降低匹配negative查询的文档的相关性得分

Query DSL - Boosting QueryQuery DSL - Boosting Query oowgsoo 发布了30 篇原创文章 · 获赞 9 · 访问量 16万+ 私信 关注
上一篇:Android编译出现DSL element android.dataBinding.enabled is obsolete and has been replaced with android


下一篇:DCM