• elasticSearch多条件高级检索语句,包含多个must、must_not、should嵌套示例,并考虑nested对象的特殊检索


    多条件高级检索模板

    多条件高级检索es语句,包含多个must、must_not、should嵌套示例,并考虑nested对象的特殊检索

    该模板适用于所有情况,尤其适用于侧边栏多级多条件联合查询

    {
        "query": {
            "bool": {
                "must": [
                    {
                        "match": {
                            "title": "Science"
                        }
                    },
                    {
                        "match": {
                            "countryArea": "United States"
                        }
                    },
                    {
                        "bool": {
                            "should": [
                                {
                                    "match": {
                                        "sponsor": "National Science Foundation"
                                    }
                                },
                                {
                                    "match": {
                                        "sponsor": "David and Lucile Packard Foundation"
                                    }
                                }
                            ],
                            "minimum_should_match": 1
                        }
                    },
                    {
                        "bool": {
                            "should": {
                                "nested": {
                                    "path": "researchAreas",
                                    "query": {
                                        "bool": {
                                            "should": [
                                                {
                                                    "match": {
                                                        "researchAreas.subjectName": "Arts and Humanities"
                                                    }
                                                },
                                                {
                                                    "match": {
                                                        "researchAreas.subjectName": "Ecology"
                                                    }
                                                }
                                            ],
                                            "minimum_should_match": 1
                                        }
                                    }
                                }
                            }
                        }
                    }
                ],
                "must_not": {
                    "match": {
                        "fundingType": "Program or Curriculum Development or Provision"
                    }
                }
            }
        }
    }
    
  • 相关阅读:
    js闭包
    python切片 []取值操作符
    python with语句
    python鸭子类型(duck type)
    python编码规范
    python @property使用详解
    python __slots__使用详解
    Python面向对象编程
    ifconfig命令详解
    5、Cocos2dx 3.0游戏开发找小三之測试例子简单介绍及小结
  • 原文地址:https://www.cnblogs.com/zys-blog/p/13207196.html
Copyright © 2020-2023  润新知