Below is my variable.
var list = [sun,moon,earth,wind,air];
db.nature.find({"name":{"$in":list}}).limit(2)
The thing is each element in the list array contains more than 5 search results..
For example: the keyword 'sun' has 5 search results, the keyword 'moon' has 5 search results the keyword 'earth' has 5 search results the keyword 'wind' has 5 search results the keyword 'air' has 5 search results... i need to limit each search results by 2..(i.e)i need to have the first two search list of every element in the list array.what can be done? The wind element in the list contains the search result as below.
{
"_id": "59229b31a8de7a8323c1e92a",
"name": "wind",
"class":"1"
}
{
"_id": "59229b31a8de7a8323c1e93a",
"name": "wind",
"class":"2"
}
{
"_id": "59229b31a8de7a8323c1e94a",
"name": "wind",
"class":"3"
}
{
"_id": "59229b31a8de7a8323c1e95a",
"name": "wind",
"class":"4"
}
{
"_id": "59229b31a8de7a8323c1e62a",
"name": "wind",
"class":"5"
}
But what i need is i need only the first two search result of every each element likewise..