Skip to content

Instantly share code, notes, and snippets.

@sbisbee
Created October 21, 2011 18:49
Show Gist options
  • Select an option

  • Save sbisbee/1304624 to your computer and use it in GitHub Desktop.

Select an option

Save sbisbee/1304624 to your computer and use it in GitHub Desktop.
Document Structure
------------------
{
_id: "whatever",
type: "some category style grouping",
date: Unix time stamp
}
Map Function
------------
function(doc) {
emit([doc.type, doc.date], 1);
}
Reduce Function
---------------
_sum
URLs & Results
--------------
?group=true
{"rows":[
{"key":["a",1],"value":1},
{"key":["a",10],"value":1},
{"key":["a",100],"value":1}
]}
?group=true&startkey=["a", 10]&group_level=1
{"rows":[
{"key":["a"],"value":2}
]}
?group=true&endkey=["a", 1]&group_level=1
{"rows":[
{"key":["a"],"value":1}
]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment