主要用于筛查必须包含和必须不包含,直接上代码:
$params = [
            'index' => 'arctile_list',
            'type' => 'arctile_type',
            'body' => [
                'query' =>[
                    'bool' =>[
                        'must' => [
                            [
                                'bool' =>[
                                    'should' =>[
                                        [
                                            'match_phrase' =>[
                                                'title' => '测试1'
                                            ]
                                        ],
                                        [
                                            'match_phrase' =>[
                                                'title' => '测试2'
                                            ]
                                        ],
                                        [
                                            'match_phrase' =>[
                                                'title' => '测试3'
                                            ]
                                        ],
                                        [
                                            'match_phrase' =>[
                                                'title' => '测试4'
                                            ]
                                        ],
                                    ]
                                ]
                            ]
                        ],
                        'must_not' => [
                            'bool' =>[
                                'should' => [
                                    [
                                        'match_phrase' =>[
                                            'title' => 'test1'
                                        ]
                                    ],
                                    [
                                        'match_phrase' =>[
                                            'title' => 'test2'
                                        ]
                                    ],
                                    [
                                        'match_phrase' =>[
                                            'title' => 'test3'
                                        ]
                                    ],
                                ]
                            ]
                        ]
                    ]
                ],
                'sort'=> [
                    'pubdate'=> [ 'order'=> 'desc' ],
                ]
            ],
            'from' => 0,
            'size' => 1,
        ];
            
                
    
    
٩(ˊᗜˋ*)و