I have a collection
[{
name: xyz
firstname : abc
lastname: ghs
country : india
},
{
name : fggh
firstname :bqjdjbw
lastname :jhhfjk
}]
Like this array of docs in mongo db, now i need to find a common key in order to optimise my queries right now if i need to find first name and last name i query like this
db.getCollection("db").find({
$or: [{name : "xyz" , country:"india"},{name : "cvnb" ,
country:"india"},]},
{"first name":1,
"lastname":1,
"_id":0 })
Can someone help me how can i find a common key or can i find id or use some algorithm to optimise it since i will eventually have to add in my java code.