elasticSearch如何使用should? [ 2.0 版本 ]
如题,我想要must为必须包含的条件,should下面匹配一个即可。怎么做啊
{
"body": {
"query": {
"bool": {
"must": [{
"terms": {
"occupations": [14, 15, 21]
}
}, {
"term": {
"check": 2
}
}],
"should": [
[{
"term": {
"is_top": 1
}
}, {
"terms": {
"top_provinces": [6]
}
}, {
"range": {
"end_time": {
"gte": 0
}
}
}],
[{
"term": {
"province": 6
}
}]
]
}
}
}
}
青山淼淼 补充于 2020-01-07 18:48
$this->queryParams['body']['query']['bool'] = [
'must' => [
['terms' => ['occupations' => [14, 15, 21]]],
['term' => ['check' => 2]],
],
'should' => [
['bool' => [
'filter' => [
['term' => ['is_top' => 1]],
['terms' => ['top_provinces' => [$provinceId]]],
['range' => ['end_time' => ['gte' => 0]]],
],
]],
['term' => ['province' => $provinceId]],
],
'minimum_should_match' => 1,
];
青山淼淼 补充于 2020-01-07 18:49
已解决
共 0 个回答
没有找到数据。
青山淼淼 四川内江
注册时间:2018-11-17
最后登录:2024-06-07
在线时长:19小时19分
最后登录:2024-06-07
在线时长:19小时19分
- 粉丝7
- 金钱7875
- 威望50
- 积分8565