簡體   English   中英

在 Kibana 中使用 ElasticSearch 查詢 DSL 從字段中獲取唯一數據

[英]Get unique data from a field using ElasticSearch query DSL in Kibana

我已經有各種查詢來收集數據並將其顯示在 Kibana 儀表板中。 現在我想從我的結果數據中獲取唯一值。 我怎樣才能為此編寫查詢 DSL。

基本上我想獲得字段 contextMap.connectionid 的唯一值。 有沒有辦法使用類似於這個例子的東西來實現這一點?

{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "app",
            "query": {
              "bool": {
                "must": [
                  {
                    "match": {
                      "app.key": "contextMap.connectionid"
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

您可以在聚合的幫助下計算不同的計數。 因此,您的搜索查詢是:

搜索查詢:

{
    "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "app",
            "query": {
              "bool": {
                "must": [
                  {
                    "match": {
                      "app.key": "contextMap.connectionid"
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  },
    "aggs": {
        "uniqueconnectionId": {
            "terms": {
                "field": "contextMap.connectionid.keyword"
            }
        }
    }
}

您可以在此處參考計算字段https://discuss.elastic.co/t/get-distinct-values-from-a-field-in-elasticsearch/99783的不同值

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM