Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using Javascript in Aggregation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chase  
View profile  
 More options Sep 5 2012, 11:02 am
From: Chase <chase.wolfin...@gmail.com>
Date: Wed, 5 Sep 2012 08:02:05 -0700 (PDT)
Local: Wed, Sep 5 2012 11:02 am
Subject: Using Javascript in Aggregation

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mathias  
View profile  
 More options Sep 5 2012, 11:44 am
From: mathias <redbeard0...@gmail.com>
Date: Wed, 5 Sep 2012 08:44:57 -0700 (PDT)
Local: Wed, Sep 5 2012 11:44 am
Subject: Re: Using Javascript in Aggregation

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mathias  
View profile  
 More options Sep 5 2012, 11:51 am
From: mathias <redbeard0...@gmail.com>
Date: Wed, 5 Sep 2012 08:51:49 -0700 (PDT)
Local: Wed, Sep 5 2012 11:51 am
Subject: Re: Using Javascript in Aggregation

Actually, you can use the technique descried here to bin on minutes:
http://stackoverflow.com/questions/11611024/binning-and-tabulate-uniq....
Note that because you cannot currently do math directly on dates, you will
need to first use $minute, etc to convert to numbers.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jenna  
View profile  
 More options Sep 5 2012, 4:01 pm
From: Jenna <jenna.deboisbl...@10gen.com>
Date: Wed, 5 Sep 2012 13:01:39 -0700 (PDT)
Local: Wed, Sep 5 2012 4:01 pm
Subject: Re: Using Javascript in Aggregation

You may also want to check out this example, which groups by date buckets:
https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/cEfW...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »