I was wonderning if there was any way to make complex selections.
Considering the following document collection:
{
image = "cab"
tags = [
[ "NNP", 0 ],
[ "NN", 1 ]
]
},
{
image = "castle"
tags = [
[ "NNP", 2 ],
[ "NN", 1 ],
[ "VB", 0 ]
]
},
(etc)
How would I express a query that checks if tags contains any element like, for instance, ["NN", ?] where I simply do not care about the integer-part of the inner array? Note that the inner array is unordered and integer values are arbitrarily assigned.
Note that I’m, absolutely new to mongodb, I might have overlooked a way to do that in the documentation. However, I was unable to use $elemMatch successfully 🙁
I suggest a little another schema:
There are three reasons why i am suggest another schema:
With above schema you can easy query for tags with some name and order:
Update:
Dot notation documentation
Hope this help!