如何组合这两个查询,以便我可以按名称搜索,发布者使用一种规则进行搜索,也可以通过不同的规则集进行搜索,所有这些都在一个查询中进行搜索?
'must'=> [
[
"multi_match" => [
"query" => $this->builder->query,
"fields" => ['name', 'publisher', 'platform'],
"fuzziness" => 'auto',
"prefix_length" => 1,
],
"match" => [
"query" => $this->builder->query,
"fields" => ['ean'],
"prefix_length" => 1
],
]
]
答案 0 :(得分:0)
我用这段代码来解决我的问题
'should'=> [
[
"multi_match" => [
"query" => $this->builder->query,
"fields" => ['name', 'publisher', 'platform'],
"fuzziness" => 'auto',
"prefix_length" => 1,
'operator' => 'or'
],
],
[
"match" => [
"ean" => $this->builder->query,
],
]
]