作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
[ "query" => [ -6ren">
这是我的搜索过滤器查询,
我想给条件加上“和”条件。
现在我已经给了必须在过滤条件内
'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/
我是一名优秀的程序员,十分优秀!