I have a view but did have duplicated documents from the results of view as like following, how can I get the duplicate results and get the unique? thank you in advance
{
"total_rows": 9,
"offset": 0,
"rows": [
{
"id": "xxxx",
"key": "12345",
"value": {
"_id": "abc123",
"_rev": "4-8db4da81d1e20afcea0a328fb16e7ec8",
"field1": "abc",
"field2": "dfr"
},
{
"id": "xxxx",
"key": "12345",
"value": {
"_id": "abc123",
"_rev": "4-8db4da81d1e20afcea0a328fb16e7ec8",
"field1": "abc",
"field2": "dfr"
},
]
}
The view is like this
function(doc) {
if(doc){
for (var i in doc.item){
emit(doc.item[i].key,doc);
}
}
}
view called by ...._view/duplicate?key="12345"
I always had this error when execute the following reduce :"error":"reduce_overflow_error","reason":"Reduce output must shrink more rapidly:
function (keys, values, rereduce) {
var uniqueKey = [];
var newValues = [];
for (var i=0; i<values.length; i++) {
if (uniqueKey.indexOf(values[i]._id)==-1) {
uniqueKey.push(values[i]._id);
newValues.push(values[i]);
}
}
return newValues;
}