Saturday, 17 August 2013

How do I find multiple items in a field with mongodb?

How do I find multiple items in a field with mongodb?

I have the following type of occurrence in my Mongo documents.
"tags" : [ [ "narnia" ], [ "aslan" ], [ "winter" ], [ "heaven" ] ]
I need to know how to find this document by matching all of any number of
the tags. I.e. Narnia AND Aslan (but not Narnia OR Aslan).
The query needs to be made with in PHP.
So far I only have it working for a single tag. I.e.
$filter['tags'] = array('$in' => array(array('Narnia')));

No comments:

Post a Comment