Azure DocumentDB - Group By Aggregates

前端 未结 2 1406
既然无缘
既然无缘 2021-01-03 00:41

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

  • number of events/day over the last week
相关标签:
2条回答
  • 2021-01-03 01:22

    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.

    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.

    0 讨论(0)
  • 2021-01-03 01:42

    For information, DocumentDB does now support Aggregates (as of March 8th 2017), for the following operations:

    SUM and AVG for numeric values, COUNT, MIN, and MAX over numbers, strings, Booleans, and nulls.

    Official Microsoft documentation has been updated, and can be found here.

    Please note that Grouping support has not been added to Aggregate Functions; a User Voice issue has been opened to request this, and can be upvoted here.

    0 讨论(0)
提交回复
热议问题