美文网首页
es实现and与or查询 --- 2023-02-15

es实现and与or查询 --- 2023-02-15

作者: 一位先生_ | 来源:发表于2023-02-14 09:50 被阅读0次
    {
        "query": {
            "bool": {
                "must": [{
                    "match_phrase": {
                        "name": "a"
                    }
                }],
                "should": [{
                    "match_phrase": {
                        "city": "b"
                    }
                },
                {
                    "match_phrase": {
                        "city": "c"
                    }
                }],
                "minimum_should_match": 1
            }
        },
        "size": 5
    }
    

    或者

                $query['query']['bool']['should'][] = [["match_phrase" => ["city" => $a]], ["match_phrase" => ["city => $b]]];
                $query['query']['bool']['minimum_should_match'] = 1;
    

    相关文章

      网友评论

          本文标题:es实现and与or查询 --- 2023-02-15

          本文链接:https://www.haomeiwen.com/subject/cghekdtx.html