zoukankan      html  css  js  c++  java
  • ES基础三 条件搜索

    (1)bool:must,must_not,should,组合多个过滤条件
    (2)bool可以嵌套
    (3)相当于SQL中的多个and条件:当你把搜索语法学好了以后,基本可以实现部分常用的sql语法对应的功能
      
     补充,在kibana中一般filter没有只能提示了。可以先在query 直接写。
    should 当一个条件是是必须含有,两个条件是满足一个即可。综合前两句是,至少满足一个条件即可。
    GET /forum/article/_search
    {
      "query": {
        "constant_score": {
          "filter": {
            "bool": {
              "should": [
                {
                  "term": {
                    "postDate": "2017-01-01"
                  }
                },
                {
                  "term": {
                    "articleID": "XHDK-A-1293-#fJ3"
                  }
                }
              ],
              "must_not": [
                {
                  "term": {
                    "postDate": "2017-01-02"
                  }
                }
              ]
            }
          }
        }
      }
    }

    上述查询是查出

    ("postDate": "2017-01-01" or "articleID": "XHDK-A-1293-#fJ3") and !("postDate": "2017-01-02")

    当需要嵌套是,不能直接bool嵌套,bool是嵌套在should,must,must_not里面的
    GET /forum/article/_search
    {
      "query": {
        "constant_score": {
          "filter": {
            "bool": {
              "should": [
                {
                  "term": {
                    "postDate": "2017-01-01"
                  }
                },
                {
                  "term": {
                    "articleID": "XHDK-A-1293-#fJ3"
                  }
                }
              ],
              "must": [
                {
                  "term": {
                    "postDate": "2017-01-02"
                  }
                },
                {
                  "bool": {
                    "should": [
                      {
                        "term": {
                          "_id": 3
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        }
      }
    }
     
  • 相关阅读:
    linux下源码安装python3
    FTP 命令
    Linux Shell数值比较和字符串比较及相关
    mount umount sort du tar
    linux 自动检查ssh脚本
    删除linux访问记录(message删不了)
    h3c 备份脚本
    linux 批量scp 脚本
    Linux 删除几天前的文件脚本
    博达交换机镜像检查,镜像丢失自动添加脚本
  • 原文地址:https://www.cnblogs.com/javabeginer/p/13060219.html
Copyright © 2011-2022 走看看