Please read the docs about indexing a document:
http://www.mongodb.org/display/DOCS/Indexes#Indexes-DocumentsasKeys
This behavior is not a bug and expected.
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>
This is not really valid or what you think it is. It will find a metro
with the exact match of this documents "{ size: { $gt : 7 } }"
> And:
>
> db.factories.find( { metro: { $gte : { size : 7 } } } )
>
> Which also uses the index, but returns both document (instead of just
> the one with size:10)
This is not what you think it is either. It will find documents which
are $gte "{size:7}", but the docs you have are of a completely
different form.
> And finally:
>
> db.factories.find( { "metro.size" : { $gt : 5 } } )
>
> which returns the correct document, but does not use the index.
You really want to index "metro.size" and not metro if this is the
query you want to use.
> So, can you point me in the right direction of how I can get either
> array values, or embedded documents to work with an index when
> performing operations other than equality?
The key fact which I think is confusing you is that created an index
of the document does not index the fields inside. It indexes the whole
document as one piece.
The array of single key/value pairs allows you to store and index arbitrary data. Does that struct work for you?
http://www.mongodb.org/display/DOCS/Indexes#Indexes-DocumentsasKeys