mongodb: Multikey indexing structure?

I think you misunderstood the difference between Multiindex and Compound indexes:

Compound indexes are user-defined indexes for multiple fields at once. Multykey indexes: MongoDB determine if the field on which the Index is released is an array and create an index for each of the array elements, for example

db.user.ensureIndex({"address.street":1});

In this case and because the target field is an Array the index will store all the items but only once.

I highly recomend you to take a look at this simple articlw that will clarify you doubts about simple imdex types in MongoDB: http://mongodbspain.com/en/2014/01/24/mongodb-indexes-part1/

Regards,


In this case, your index (which is a B-tree) would look like this:

 apollo => [ obj1 ]
 atlantis => [ obj2 ]
 moon => [ obj1 ]
 nasa  => [ obj1, obj2 ]
 space => [ obj2 ]
 spaceflight => [ obj1, obj2 ]

This is just a "regular" B-tree index, except that every document can appear more than once (it appears once for every unique tag value).