主页

主要用于筛查必须包含和必须不包含,直接上代码:

$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,
        ];

版权属于:三分快乐,七纷幸福
作品采用:本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
1
查看目录

目录

来自 《Elasticsearch 组合多查询》
评论

  1. 评论头像
    2022-11-24 回复

    ٩(ˊᗜˋ*)و

三分快乐,七纷幸福
99 文章数
7 评论量
11 分类数
102 页面数
已在风雨中度过 2年199天23小时51分