Azure DocumentDB - Aggregate Group

I have a team in Elastic Search, where we store events, and summarize them in reports such as:

  • number of events / days in the last week
  • number of events / hour in the last 24 hours

enter image description here

We would like to switch to DocumentDB, but without GROUPING support I don’t see how I could implement this without making 7 + 24 queries. Any ideas?

thanks

+5
source share
2 answers

Based on my understanding, you want to transfer event data to DocumentDb as a document in a collection. As you said, DocumentDb now does not support aggregate operations, but the function will be supported in the future, as the official site said. However, in my experience, you can use the DocumentDb stored procedure to fulfill your needs and automatically calculate the number of event documents for the periods that you want to save as a new document in a new collection, which per day / hour through the database trigger, refer to the official tutorial DocumentDB server-side programming: stored procedures, database triggers, and UDF to find out.

In the meantime, I found the SO Streaming Field Grouping in DocumentDB , which is very useful for you. Responder wrote a documentdb-lumenize library based on a DocumentDb stored procedure that you can try.

+4
source

For information, DocumentDB now supports aggregates (as of March 8, 2017) for the following operations:

SUM and AVG for numerical values COUNT , MIN and MAX by numbers, lines, logical and zero values.

The official Microsoft documentation has been updated and can be found here .

Note that grouping support is not added to aggregate functions; To request this request, a problem was opened with the user's voice message and can be saved here .

+5
source

Source: https://habr.com/ru/post/1264885/


All Articles