[ "query" => [ -6ren">
gpt4 book ai didi

elasticsearch - Elasticsearch AND条件与词条查询

转载 作者:行者123 更新时间:2023-12-03 01:52:13 25 4
gpt4 key购买 nike

这是我的搜索过滤器查询,
我想给条件加上“和”条件。
现在我已经给了必须在过滤条件内

'query' => [
"filtered" => [
"query" => [
"match_all" => []
],
"filter" => [
"bool" => [
"must" => [
"terms" => [
"num" => [
1,2,3
]
],
"terms" => [
"sample" => [
"a", "b"
],
]
]
]
],
'query' => [
'multi_match' => [
'query' => "Hello",
'fields' => ['text'],
'operator' => 'and'
],
]
]
],

但它不起作用。还有其他解决方案吗?

最佳答案

您需要将terms过滤器再封装一个数组,否则bool/must会成为关联数组,而这并不是您想要的(即,其中一个terms过滤器被丢弃了)。

'query' => [
"filtered" => [
"query" => [
"match_all" => []
],
"filter" => [
"bool" => [
"must" => [
[ <---
"terms" => [
"num" => [
1,2,3
]
]
], <---
[ <---
"terms" => [
"sample" => [
"a", "b"
],
]
] <---
]
]
],
'query' => [
'multi_match' => [
'query' => "Hello",
'fields' => ['text'],
'operator' => 'and'
],
]
]
],

关于elasticsearch - Elasticsearch AND条件与词条查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39408897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com