0

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

以下查询不起作用,我认为它需要更改和更正。

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

最初的要求是在Kibana仪表板中保存一个过滤器,其范围为 400-600 或者它丢失了。

4

1 回答 1

2

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

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"
              }
            }
          }
        }
      ]
    }
  }
}
于 2018-05-23T12:50:06.173 回答