我們在Elasticsearch中有一組日誌,每個組包含共享一個唯一ID(名爲transactionId)的1-7個日誌。每個組中的每個日誌都有一個唯一的時間戳(eventTimestamp)。用具有唯一ID的組返回具有最新時間戳的日誌
例如:
{
"transactionId": "id111",
"eventTimestamp": "1505864112047",
"otherfieldA": "fieldAvalue",
"otherfieldB": "fieldBvalue"
}
{
"transactionId": "id111",
"eventTimestamp": "1505864112051",
"otherfieldA": "fieldAvalue",
"otherfieldB": "fieldBvalue"
}
{
"transactionId": "id222",
"eventTimestamp": "1505863719467",
"otherfieldA": "fieldAvalue",
"otherfieldB": "fieldBvalue"
}
{
"transactionId": "id222",
"eventTimestamp": "1505863719478",
"otherfieldA": "fieldAvalue",
"otherfieldB": "fieldBvalue"
}
我需要編寫返回所有所有transactionIds的最新時間戳在一定日期範圍內的查詢。
我簡單的例子繼續,查詢的結果應該返回這些日誌:
{
"transactionId": "id111",
"eventTimestamp": "1505864112051",
"otherfieldA": "fieldAvalue",
"otherfieldB": "fieldBvalue"
}
{
"transactionId": "id222",
"eventTimestamp": "1505863719478",
"otherfieldA": "fieldAvalue",
"otherfieldB": "fieldBvalue"
}
如何建立,完成此查詢任何想法?