i have failry simple structure documents: {regid: 1, data: {[{val: 123456}, {val: 324234}, {val: 4353453}, .......]}} the data element array may contain between 30 , 60 sub-documents , collection has ~53000 documents, grow larger. given array of vals, input, [11563012,11563011,82867218,83866648, ....], want return documents have @ least 3 matching data.val. currently, query using $in modifier , $where clause calls js function (countmatches). $in modifier returns document contains @ least 1 item imput , $where function iterates through each document.date, counting matches in input , returns documents above threshold: db.foo.find({"data.val": {$in: [11563012,11563011,82867218,83866648,.......]}, $where: "countmatches(this.data, [11563012,11563011,82867218,83866648,......])>=3"}).count(); similar questions (http://groups.google.com/group/mongodb-user/browse_thread/thread/fa291575fd47c010) seem indicate way count matchs in "sub-documents"...