Hi - Is it possible to use javascript in the group by part of the aggregation framework? Specifically I have statistic entry that has a date and I am trying to round these to the nearest minute, 5 minute, 15 minute, 1 hour interval so I can sum or average all values over a period. I have checked the mongo docs and it does not seem possible.
Currently there are no plans to support js inside of the aggregation framework. If you really need that, you will have to use map/reduce.
You can use $minute / $hour, etc inside of a group to group by time. Doing the 5 and 15minute bucketing will be tricky, but should be possible using nested $cond (http://docs.mongodb.org/manual/reference/aggregation/#_S_cond). Please feel free to create a jira ticket to make time bucketing easier.
Also, you will need to do each bucket size as a separate aggregation as each $group is currently limited to a single key. I am considering lifting that restriction for 2.2, but not sure yet.
On Wednesday, September 5, 2012 11:02:05 AM UTC-4, Chase wrote:
> Hi - Is it possible to use javascript in the group by part of the > aggregation framework? Specifically I have statistic entry that has a date > and I am trying to round these to the nearest minute, 5 minute, 15 minute, > 1 hour interval so I can sum or average all values over a period. I have > checked the mongo docs and it does not seem possible.
On Wednesday, September 5, 2012 11:44:57 AM UTC-4, mathias wrote:
> Currently there are no plans to support js inside of the aggregation > framework. If you really need that, you will have to use map/reduce.
> You can use $minute / $hour, etc inside of a group to group by time. Doing > the 5 and 15minute bucketing will be tricky, but should be possible using > nested $cond ( > http://docs.mongodb.org/manual/reference/aggregation/#_S_cond). Please > feel free to create a jira ticket to make time bucketing easier.
> Also, you will need to do each bucket size as a separate aggregation as > each $group is currently limited to a single key. I am considering lifting > that restriction for 2.2, but not sure yet.
> On Wednesday, September 5, 2012 11:02:05 AM UTC-4, Chase wrote:
>> Hi - Is it possible to use javascript in the group by part of the >> aggregation framework? Specifically I have statistic entry that has a date >> and I am trying to round these to the nearest minute, 5 minute, 15 minute, >> 1 hour interval so I can sum or average all values over a period. I have >> checked the mongo docs and it does not seem possible.
> On Wednesday, September 5, 2012 11:44:57 AM UTC-4, mathias wrote:
>> Currently there are no plans to support js inside of the aggregation >> framework. If you really need that, you will have to use map/reduce.
>> You can use $minute / $hour, etc inside of a group to group by time. >> Doing the 5 and 15minute bucketing will be tricky, but should be possible >> using nested $cond ( >> http://docs.mongodb.org/manual/reference/aggregation/#_S_cond). Please >> feel free to create a jira ticket to make time bucketing easier.
>> Also, you will need to do each bucket size as a separate aggregation as >> each $group is currently limited to a single key. I am considering lifting >> that restriction for 2.2, but not sure yet.
>> On Wednesday, September 5, 2012 11:02:05 AM UTC-4, Chase wrote:
>>> Hi - Is it possible to use javascript in the group by part of the >>> aggregation framework? Specifically I have statistic entry that has a date >>> and I am trying to round these to the nearest minute, 5 minute, 15 minute, >>> 1 hour interval so I can sum or average all values over a period. I have >>> checked the mongo docs and it does not seem possible.