ElasticSearch6 影響_score的兩種方式

影響score兩種方式都要用到 function_scorespa

1. field_value_factorcode

        "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_factorblog

"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",],
相關文章
相關標籤/搜索