How can I derived from only the document in the last XXX months (based on ticket's lastUpdateDateTime field's value). The list is still sorted by the number of occurrences (how often is used), in descending order.
Currently I can sort by the number of occurrences, how to retrieve the document with the time limit at the sametime
call the view like : ......?startkey=["UserId"]&endkey=["UserId",{}]&group=true
Map:
function(doc) {
var usersLength = doc.users.length;
for (var i = 0; i < usersLength ; i++) {
emit([doc.users[i].UserId,doc.emailAddress,doc.serialNumber], 1);
}
}
reduce:
function(keys, values, rereduce)
{
return sum(values);
}
the results
{"rows":[
{"key":["3432950","dd@dd"],"value":8},
{"key":["3432950","aa@aa"],"value":8},
{"key":["3432950","bb@bb"],"value":1},
{"key":["3432950","cc@cc"],"value":1}
]}
call the view like : ......?startkey=["UserId"]&endkey=["UserId",{}]&group=true