![](/img/trans.png)
[英]How to write search queries in kibana using Query DSL for Elasticsearch aggregation
[英]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.