I have a document with a nested document; here is a snippet:
"gender": "M",
"flags_blacklist": "",
"ids": [
{
"expires": "02-JUN-2015",
"type": "1",
"id": "134453232443"
}
],
"maritial_status": "M",
"dependents": "",
I would like to write a view to filter those documents that have any id of type “1”, here is my attempt:
function (doc, meta) {
if (doc.ids) {
for (var x = 0; x < len(doc.ids); x++) {
if (doc.ids[x].type == "1") {
emit(doc.cif, doc.ids);
}
}
}
}
cif is a key I would like to be used.
This view does not filter any documents; even though the sample random document fits the criteria; any idea what I am doing wrong here?