2020-01-06 20:33:55 2315次浏览 0条回答 0 悬赏 100 金钱

如题,我想要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

已解决

    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
青山淼淼
副总裁

青山淼淼 四川内江

注册时间:2018-11-17
最后登录:2024-06-07
在线时长:19小时19分
  • 粉丝7
  • 金钱7875
  • 威望50
  • 积分8565

热门问题