ElasticSearch6 影响_score的两种方式

影响score两种方式都要用到 function_score

1. field_value_factor

        "function_score" => [
                    "query" => [
                        "bool" => [
                            "must" => [
                                ["term" => ["title" => $xx]],
                               
                            ],
                            "must_not" => [
                                "terms" => ["xx" => "xx"],
                            ],
                        ],
                    ],
                    "field_value_factor" => [
                        "field" => "replies",
                        "modifier" => "log1p"
                     ]
                    "boost_mode" => "sum",



                ]

 

2. field_value_factor

"function_score" => [
"query" => [
"bool" => [
"must" => [
          ["term" => ["title" => $xx]]
            ],
],
],

"script_score" => [
"script" => "return (doc['a'].value * 0.6 + doc['b'].value * 0.2 + doc['c'].value * 0.1 + doc['d'].value * 0.1) * _score"
],
"boost_mode" => "replace",

],
posted @ 2018-10-10 13:59  zhjahch  阅读(2279)  评论(0编辑  收藏  举报