我正在努力获得一个查询来处理elasticsearch,我将multi_match查询与字段提升, field_value_factors 组合在一起,然后是一个应该提升的函数任何与特定文档类型匹配的文档。
除了我在第二个查询中添加了以下错误的函数子句时,查询完美无缺:
您可以定义[functions]数组或单个函数,而不是两者。已找到[field_value_factor],现在遇到[functions]
要清楚......
我的目标是使用下面的“功能”块将包含与“html”一词匹配的字段“doctype”的任何文档提升10倍
此作品
$param = json_encode(
array(
"query" => array(
"function_score" => array(
"query" => array(
"multi_match" => array(
"query" => $query,
"fields" => array("title^5","body"),
"fuzziness" => 1
)
),
"field_value_factor" => array(
"field" => "hits",
"modifier" => "log1p",
"factor" => 10
),
"field_value_factor" => array(
"field" => "weight",
"modifier" => "log1p",
"factor" => 3
)
)
),
"size" => $offset,
"from" => $start
)
);
将以下子句添加到第二个查询不起作用
"functions" => [array("filter" => array("term" => array("doctype" => "html")), "boost_factor" => 10)],
"max_boost" => 10,
"boost_mode" => "multiply"
**完整查询 - 这不起作用**
$param = json_encode(
array(
"query" => array(
"function_score" => array(
"query" => array(
"multi_match" => array(
"query" => $query,
"fields" => array("title^5","body"),
"fuzziness" => 1
)
),
"field_value_factor" => array(
"field" => "hits",
"modifier" => "log1p",
"factor" => 10
),
"field_value_factor" => array(
"field" => "weight",
"modifier" => "log1p",
"factor" => 3
),
"functions" => [
array("filter" => array("term" => array("doctype" => "html")), "boost_factor" => 10)
],
"max_boost" => 10,
"boost_mode" => "multiply"
)
),
"size" => $offset,
"from" => $start
)
);