we have a nice little CouchDB running storing some user habit data for the people using our website.
A sample entry looks like this:
{
"_id": "5a2711671b321c6295acfe04700e3d32",
"_rev": "1-a74c2d88a8277d9ad7ceb74406c9bb9e",
"search_term": "dream_theater",
"timestamp": 1447255047,
"session_id": "qjrsh7cq10oa9m1mebdikdcvg3",
"ip_address": "THE IP",
"browser": "Safari",
"browser_version": "9.0.1",
"platform": "Macintosh",
"service": [
],
"content_type": [
],
"language": "en",
"limit": 100
}
Right now I wrote several MapReduce functions to access this habit data and extract information out of it. An example looks like this:
"by_platform_browser": {
"map": "function(doc) { if (doc.browser && doc.platform) emit([doc.platform, doc.browser], 1) }",
"reduce": "function(keys, values, rereduce) { return sum(values) }"
}
This returns me some stuff like this (with group=true):
{"rows":[
{"key":["Linux","Chrome"],"value":198},
{"key":["Linux","Firefox"],"value":129},
{"key":["Macintosh","Chrome"],"value":36},
{"key":["Macintosh","Safari"],"value":135},
{"key":["Windows","Chrome"],"value":37}
]}
As you see there is a timestamp field in each habit data document.
Now to my question itself:
How can I just collect data between a given amount of time. Like starting at epoch 1447255000 and ending at 1447266000.
When I combine keys I cannot use the group.
Is there some other way to solve this?
Thank you so much in advance! //Jonas