I have the following document
{
"Credit_Amount": 99,
"Acc_no": 138,
"Job_No": "esmwga",
"Source_No": "x",
"Temp": 1017,
"Document_No": "gaf",
"Debit_Amount": 67,
"User_Id": "xirbzsewiw"
}
and my map function is this
function (doc, meta) {
if(doc.Type == "GLEntry")
{
emit([doc.Acc_no,doc.User_Id],[doc.Credit_Amount,doc.Debit_Amount]);
}
}
and this is my reduce function
function(key,values,rereduce){
var sum1=0,sum2=0;
for(var i=0;i<values.length;++i)
{
sum1+=values[i][0];
sum2+=values[i][1];
}
return ([sum1,sum2])
}
when I pass this key
[138,"xirbzsewiw"]
group level 2
I get this output
[ 99, 67 ]
But When I give this as key
[138]
group level 1
I get empty result. But what I have understood is it will group using only acc number when I give group level 1 so it should give same output. Am I doing something wrong?