代码之家  ›  专栏  ›  技术社区  ›  Julian Camilleri

范围或缺失-ElasticSearch-查询DSL

  •  0
  • Julian Camilleri  · 技术社区  · 7 年前

    我目前正在尝试将以下逻辑放入ES查询中-是吗 http_code 是否存在?如果是这样,它应该在400-600之间,但也可能丢失。

    下面的查询不起作用,我认为需要修改和更正。

    {
      "query": {
        "bool": {
          "must": [
            {
              "range": {
                "http_code": {
                  "gte": 400,
                  "lt": 600
                }
              }
            },
            {
              "bool": {
                "should": [
                  {
                    "bool": {
                      "must_not": {
                        "exists": {
                          "field": "http_code"
                        }
                      }
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    }
    

    最初的要求是在 基巴纳 仪表板范围400-600或丢失。

    1 回复  |  直到 7 年前
        1
  •  0
  •   jordivador    7 年前

    要进行您建议的查询,需要执行以下操作:

    The original requirement is to save a filter in a Kibana dashboard with range 400-600 OR it's missing. as:

    {
      "query": {
        "bool": {
          "minimum_should_match": 1,
          "should": [
            {
              "range": {
                "http_code": {
                  "gte": 400,
                  "lt": 600
                }
              }
            },
            {
              "bool": {
                "must_not": {
                  "exists": {
                    "field": "http_code"
                  }
                }
              }
            }
          ]
        }
      }
    }
    
    推荐文章