连续间隔内的Elasticsearch聚合

时间:2019-12-15 13:08:49

标签: elasticsearch time-series aggregation

我有这样的文件:

[
    {
        "code": "code1",
        "dateFrom": "T1",
        "dateTo": "T2",
        "attr1": "valA1",
        "attr2": "valA2"
    }, {
        "code": "code1",
        "dateFrom": "T2",
        "dateTo": "T3",
        "attr1": "valA1",
        "attr2": "valA2"
    }, {
        "code": "code1",
        "dateFrom": "T3",
        "dateTo": "T4",
        "attr1": "valA1",
        "attr2": "valA2"
    }, {
        "code": "code1",
        "dateFrom": "T7",
        "dateTo": "T8",
        "attr1": "valA1",
        "attr2": "valA2"
    }
]

现在,我想在代码dateFrom,dateTo,attr1,attr2上创建术语聚合,但要考虑到日期间隔<dateFrom, dateTo)。如果间隔是连续的,则它们应该属于同一存储桶,但范围要扩大。如果可能,创建像这样的汇总结果的最佳方法是什么:

    {
        "code": "code1",
        "dateFrom": "T1",
        "dateTo": "T4",
        "attr1": "valA1",
        "attr2": "valA2"
    }, {
        "code": "code1",
        "dateFrom": "T7",
        "dateTo": "T8",
        "attr1": "valA1",
        "attr2": "valA2"
    }

谢谢。

0 个答案:

没有答案