Count how many documents contain a field
<p>I have these three MongoDB documents:</p>

<pre><code>{ 
    "_id" : ObjectId("571094afc2bcfe430ddd0815"), 
    "name" : "Barry", 
    "surname" : "Allen", 
    "address" : [
        {
            "street" : "Red", 
            "number" : NumberInt(66), 
            "city" : "Central City"
        }, 
        {
            "street" : "Yellow", 
            "number" : NumberInt(7), 
            "city" : "Gotham City"
        }
    ]
}

{ 
    "_id" : ObjectId("57109504c2bcfe430ddd0816"), 
    "name" : "Oliver", 
    "surname" : "Queen", 
    "address" : {
        "street" : "Green", 
        "number" : NumberInt(66), 
        "city" : "Star City"
    }
}
{ 
    "_id" : ObjectId("5710953ac2bcfe430ddd0817"), 
    "name" : "Tudof", 
    "surname" : "Unknown", 
    "address" : "homeless"
}
</code></pre>

<p>The <code>address</code> field is an <code>Array</code> of Objects in the first document, an <code>Object</code> in the second and a <code>String</code> in the third.
My target is to find how many documents of my collection containinig the field <strong><code>address.street</code></strong>. In this case the right count is 1 but with my query I get two:</p>

<pre><code>db.coll.find({"address.street":{"$exists":1}}).count()
</code></pre>

<p>I also tried map/reduce. It works but it is slower; so if it is possible, I would avoid it. </p>