1
我有一些基於時間的嵌套數據,我希望得到最大的變化,正面和負面,每月plugins
。我使用Elasticsearch 5.3(和Kibana 5.3)。Elasticsearch:獲得頂級嵌套文檔每月沒有頂級副本
的文檔結構如下:
{
_id: "xxx",
@timestamp: 1508244365987,
siteURL: "www.foo.bar",
plugins: [
{
name: "foo",
version: "3.1.4"
},
{
name: "baz",
version: "13.37"
}
]
}
然而,每個ID(siteURL
),我每月有多個條目,我想只用每次鬥最新的,以避免不公平的秤。 我試着用以下的聚合,從而解決這個問題:
{
"aggs": {
"normal_dates": {
"date_range": {
"field": "@timestamp",
"ranges": [
{
"from": "now-1y/d",
"to": "now"
}
]
},
"aggs": {
"date_histo": {
"date_histogram": {
"field": "@timestamp",
"interval": "month"
},
"aggs": {
"top_sites": {
"terms": {
"field": "siteURL.keyword",
"size": 50000
},
"aggs": {
"top_plugin_hits": {
"top_hits": {
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
],
"_source": {
"includes": [
"plugins.name"
]
},
"size": 1
}
}
}
}
}
}
}
}
}
}
現在我每月獲得最新的網站,它的插件。接下來,我想將數據從裏面翻出來,並獲取每個月的插件數量和出現次數。然後我會使用serial_diff比較幾個月。
但是,我不知道如何從我的聚合到串行比較,即將數據從裏面出來。
任何幫助將是最受歡迎的
PS:多餘的榮譽,如果我能在Kibana 5.3表得到它...