【问题标题】:2 filter dsl query looks the same and how to combine2 过滤dsl查询看起来一样以及如何组合
【发布时间】:2019-10-19 17:38:50
【问题描述】:

在 Kibana 中,我创建了 2 个过滤器: raw.browserJs.isWebDriver 为真,而 raw.browserJs.isWebDriver 不为真。为什么两者的编辑查询 DSL 相同:

{
  "query": {
    "match": {
      "raw.browserJs.isWebDriver": {
        "query": true,
        "type": "phrase"
      }
    }
  }
}

另外,我如何添加条件以便拥有一个大型 DSL 查询:

{
  "query": {
    "match": {
      "appName": {
        "query": "temp",
        "type": "phrase"
      }
    }
  }
}

【问题讨论】:

    标签: kibana querydsl


    【解决方案1】:

    在 Kibana 中显示的查询 DSL 并不是发送到 elasticsearch 的实际查询。为选定时间段添加范围过滤器并反转过滤器。您可以在浏览器中发送的基础请求中看到实际查询。

    您在 raw.browserJs.isWebDriver 不正确的地方进行过滤,最终会出现如下结果:

    {
      "query": {
        "bool": {
          "must_not": [
            {
              "match_phrase": {
                "raw.browserJs.isWebDriver": true
              }
            }
          ]
        }
      }
    }
    

    您可以使用布尔查询在一个 DSL 查询中组合多个条件。(https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

    以下查询将适用于您的示例:

    {
      "query": {
        "bool": {
          "must": [
            {
              "match_phrase": {
                "raw.browserJs.isWebDriver": true
              }
            },
            {
              "match_phrase": {
                "appName": "temp"
              }
            }
          ]
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-02-17
      • 1970-01-01
      • 1970-01-01
      • 2021-08-27
      • 2023-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-01
      相关资源
      最近更新 更多