影响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",

],

发表评论