Answer the question
In order to leave comments, you need to log in
Where is the error in the $elemMatch request?
View request
db.getCollection('mycollection').find({"tags.tourism":"hotel"})
db.getCollection('mycollection').find({"tags":{$elemMatch:{"tourism":"hotel"}}})
{"tourism":"hotel","building":"yes"}
{
"_id" : ObjectId("56d37e89b10135ea7a45980f"),
"timestamp" : "2016-02-28T22:53:42.597Z",
"tags" : {
"building" : "yes",
"name" : "Amish View Inn & Suites",
"tourism" : "hotel"
},
"type" : "adrpnt"
}
Answer the question
In order to leave comments, you need to log in
Quotes should be removed
$elemMatch is not suitable for this structure here, because it works on the list, that is, it worked when the data was like this:
"tags" : [{
"building" : "yes",
"name" : "Amish View Inn & Suites",
"tourism" : "hotel"
}]
db.mycollection.find({"tags.tourism":"hotel", "tags.building":"yes"})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question