I have the following task: got all users from site and where timestamp from X to Y and has events “Proposal start”, “Proposal end” also group them by the timestamp.
So I wrote the following map function:
function (doc, meta) {
if (meta.type === ‘json’ && doc.type === ‘session’ && doc.events.length > 0) {
for (var i=0; i < doc.events.length; i++){
emit([doc.site, doc.ts.toString(), doc.events[i]], 1);
}
}
}
…reduce is just a _count.
I test my MapReduce with the next params:
startkey = [“site.com”, “1384293600000”, “Proposal start”]
endkey = [“site.com”, “1385330399999”, “Proposal end”]
group_level=2
reduce=true
But as a result, I get the data that do not meet the specified parameters. I get the data that satisfy the conditions of only the first two arguments site and timestamp.
Yes, I know about the specific numbering for gepup_level. When you set a group_level=2 the filter works only on the first two elements. This is my problem, I need to filter for all elements, not only for the first two.