Reputation: 60
We have db like this:
{
tags : ["key1", "key2", "key3", "car", "etc.."],
question : "some text here "
},
{
tags : ["bla1", "bla2", "bla3", "etc.."],
question : "My car is here"
}
I need query, that will get both rows with keyword "car"
I tried:
db.some.find(
'$or' : [ ["tags" : "car" ], [ "$text" : [ "$search" : "car" ] ] ]
);
"question" is text index
Upvotes: 1
Views: 51
Reputation: 37038
Unless you need to use $text
, you can use plain $regex
:
db.some.find({ $or:[ {tags:"car"}, {question:/car/} ] })
Upvotes: 3