Created
August 9, 2010 16:04
-
-
Save scotthernandez/515635 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.test7.insert({firstName: 'testme',lastName: 'testme', devices: [{address: '[email protected]', type: 'EMAIL'}]}) | |
> db.test7.ensureIndex({'devices.address': 1, 'devices.type': 1}) | |
> db.test7.find({devices: { $elemMatch: {address: /^testme/, type: 'EMAIL'}}}).explain() | |
{ | |
"cursor" : "BtreeCursor devices.address_1_devices.type_1 multi", | |
"nscanned" : 1, | |
"nscannedObjects" : 1, | |
"n" : 1, | |
"millis" : 1, | |
"indexBounds" : { | |
"devices.address" : [ | |
[ | |
"testme", | |
"testmf" | |
], | |
[ | |
/^testme/, | |
/^testme/ | |
] | |
], | |
"devices.type" : [ | |
[ | |
"EMAIL", | |
"EMAIL" | |
] | |
] | |
} | |
} | |
> db.test7.find({devices: { $elemMatch: {address: {$regex:"^testme"}, type: 'EMAIL'}}}).explain() | |
{ | |
"cursor" : "BasicCursor", | |
"nscanned" : 1, | |
"nscannedObjects" : 1, | |
"n" : 1, | |
"millis" : 0, | |
"indexBounds" : { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment