I'm trying to do some profiling of a MongoDB "$or" query and I'm having trouble with the 'explain()' command in the Mongo shell. When I run my query with the find command, it works and returns one record, as expected. When I tack on an 'explain()' at the end of the find() however, I get the following error:
uncaught exception: error: { "$err" : "invalid operator: $or", "code" : 10068 }
I'm trying the following query:
db.people.find({"query" :
{"$or" : [
{"site" : "mysite", "site_id" : "587125722"},
{"user_id" : ObjectId("4fb811aae4b0b628b485a58d")}
]},
"$orderby" : { "global_id" : 1, "user_id" : 1}
})
If I change the "$or" to "or", explain() works fine, but the query returns 0 results. I was under the impression that they syntax should be the same with or without explain(), so what am I doing wrong? I'm using version 2.0.4. Thanks to anyone who may be able to help.