I just tried it and it worked with 2.2.0 copying directly from above into the console.
Are you sure the version of the server you are running is 2.2.0? I only ask because the error I get back for a bad operator includes a error 'code'. Can you try the following to verify?
> db.serverStatus().version
2.2.0
> version()
version: 2.2.0
Rob.
On Friday, August 31, 2012 11:05:37 PM UTC-4, threecuptea wrote:
I am learning MongoDB and found that I got "invalid operator: $elemMatch" whenever I use $elemMatch in the query no matter I follow the example in "Seven Database in Seven Weeks" or following MongoDB Advanced Query tutorial. The followings are excerpt.
> db.documents.insert( {
... Name: "name1",
... Identifiers: [
... { name: "manufacturer26", value: "abc123" },
... { name: "store5", value: "tty3" },
... { name: "factory3", value: "521" }
... ]
... } );
> db.documents.find( { "Identifiers": {$elemMatch: { name: "store5", value: "tty3" } } } );
error: { "$err" : "invalid operator: $elemMatch" }
I have the most recent version (2.2.0) of MongoDB. Did I miss something? How do I get it to work?
Thanks.