Azure DocumentDB-汇总分组 [英] Azure DocumentDB - Group By Aggregates

查看:63
本文介绍了Azure DocumentDB-汇总分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Elastic Search中有一个大学学院,我们在其中存储事件,并将这些事件汇总到报告中,例如:

I have a colleciton in Elastic Search where we store events, and aggregate these in reports such as:

  • 上周每天的活动数
  • 过去24小时每小时的事件数
  • number of events/day over the last week
  • number of events/hour over the last 24h

我们想迁移到DocumentDB,但是由于不支持GROUPING,所以我不知道如何在不进行7 + 24查询的情况下实现这一点.有什么想法吗?

We'd like to move to DocumentDB, but with no support for GROUPING, I don't see how I could implement this without making 7+24 queries. Any ideas?

谢谢

推荐答案

基于我的理解,您希望将事件数据作为集合中的文档移至DocumentDb.如您所说,DocumentDb现在不支持聚合操作,但是如官方站点所说,将来将支持该功能.但是,根据我的经验,您可以使用DocumentDb的存储过程来满足您的需求,并自动将每个期间要存储的事件文档的数量计数为每天/小时的新集合的新文档.通过数据库触发器,请参考官方教程 DocumentDB服务器端编程:存储过程,数据库触发器和UDF 都知道.

Based on my understanding, you want to move your event data to DocumentDb as a document in a collection. As your said, DocumentDb is not support for aggregate operations now, but the feature will be supported in the future as the offical site said. However, per my experience, you can use the stored procedure of DocumentDb to implement your needs, and automatically count the number of the event documents per the periods as you want to store as a new document of a new collection which for per day/hour via database trigger, please refer to the offical tutorial DocumentDB server-side programming: Stored procedures, database triggers, and UDFs to know it.

同时,我发现了一个SO线程按DocumentDB中的字段分组这对您非常有帮助.答复者已基于文档Db存储过程编写了一个 documentdb-lumenize 库,您可以尝试使用该库.

Meanwhile, I discovered a SO thread Grouping by a field in DocumentDB which is very helpful for you. The answerer has written a library documentdb-lumenize based on DocumentDb stored procedure that you can try it.

这篇关于Azure DocumentDB-汇总分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆