Mongo DB聚合管道

时间:2018-11-03 07:38:57

标签: mongodb aggregation-framework

我是Mango DB的新手,谁能解释如何在一个查询结果中从中获取以下统计信息

  • 由“ lastActionTimestamp”组成的小组
  • 我们应该获得“ extractionFinished”,“ transformationFinished”,“ loadFinished”,失败和status = duplicate文档总数。有人可以帮忙吗?

样本数据集:

   "migration" : {
            "sourceSystem" : "Test",
            "targetSystem" : "Test2",
            "lastAction" : "load finished",
            "lastActionTimestamp" : ISODate("2018-04-28T19:08:00.335Z"),
            "extractionStarted" : ISODate("2018-04-14T02:22:46.882Z"),
            "extractionFinished" : ISODate("2018-04-14T02:22:46.882Z"),
            "failed" : false
            "status" : "Valid",
            "deltaStatus" : false,
            "transformationStarted" : ISODate("2018-04-22T14:33:46.020Z"),
            "transformationFinished" : ISODate("2018-04-22T14:33:46.023Z"),
            "loadStarted" : ISODate("2018-04-28T19:07:58.803Z"),
            "loadFinished" : ISODate("2018-04-28T19:08:00.336Z"),
            "failureReason" : ""
        }

        "migration" : {
            "sourceSystem" : "Test",
            "targetSystem" : "Test2",
            "lastAction" : "load finished",
            "lastActionTimestamp" : ISODate("2018-04-28T19:08:00.335Z"),
            "extractionStarted" : ISODate("2018-04-14T02:22:46.882Z"),
            "extractionFinished" : ISODate("2018-04-14T02:22:46.882Z"),
            "failed" : true
            "status" : "Valid",
            "deltaStatus" : false,
            "transformationStarted" : ISODate("2018-04-22T14:33:46.020Z"),
            "transformationFinished" : ISODate("2018-04-22T14:33:46.023Z"),

            "failureReason" : "Some Issue"
        }
        "migration" : {
            "sourceSystem" : "Test",
            "targetSystem" : "Test2",
            "lastAction" : "load finished",
            "lastActionTimestamp" : ISODate("2018-04-28T19:08:00.335Z"),
            "extractionStarted" : ISODate("2018-04-14T02:22:46.882Z"),
            "extractionFinished" : ISODate("2018-04-14T02:22:46.882Z"),
            "failed" : False
            "status" : "Duplicate",
            "deltaStatus" : false,
            "transformationStarted" : ISODate("2018-04-22T14:33:46.020Z"),
            "transformationFinished" : ISODate("2018-04-22T14:33:46.023Z"),

            "failureReason" : ""
        }

预期输出:

提取完成:3 转换完成:3 完成负载:1 重复:1 失败:1

0 个答案:

没有答案