在mongodb中使用AND在同一个键上

I have a key in my document whose structure is as follow:

"tag": [
    {
      "schemeName": "http:\/\/somesite.com\/categoryscheme2",
      "name": "Test Tag2",
      "value": 1,
      "slug": "test_tag2"
    },
    {
      "schemaName": "http:\/\/somesite.com\/categoryscheme3",
      "name": "Test Tag3",
      "value": 1,
      "slug": "test_tag3"
    }
  ]

Now, I get inputs as tag=test_tag2ANDtest_tag3. How can I write a query for this? I tried to iterate through the loop but I didnt got any results.

Correct me if I am wrong but you don't need an $and or $elemMatch, instead:

$mongodb->collection->find(array('tags.slug'=>array(
    '$in' => array('test_tag2','test_tag3'))))

Should work, however, if your English suggests what a second read does, then you can also use $all in place of $in. This will ensure that all root documents must have those slugs in them.

use $elemMatch operator to match elements inside the array.