Remove duplicate document from view result


#1

View:
function (doc, meta) {
if(doc.doc_type==“phone”) {
var s_search = doc.title.toString()+’ ‘+doc.model.toString()+’ '+doc. detail ();
s_search = s_search.toLowerCase();
var namesarray = s_search.split(" ");
for(var i=0;i<namesarray.length;i++)
{
emit(namesarray[i].toLowerCase(), doc.title);
}
}
}

Documents:

Phone1:{
“title”: “iphone”,
“model”: “iphone 5”,
“doc_type”: “phone”,
“detail”: “its iphone 5”,
}
Phone2:{
“title”: “iphone”,
“model”: “iphone 6”,
“doc_type”: “phone”,
“detail”: “its iphone 6”,
}

Now if I pass “iphone” as key for searching , my view will return the document title 6 times, I want to remove the duplicate document, one document display only one time, if key matches.