A. How do I index nested
and all of it's values?
B. How do I index valuetwo
?
{ id: 00000, attrs: { nested:{ value: value1, valuetwo: value2, } } }
I've looked here: http://www.mongodb.org/display/DOCS/Indexes, and the docs to my knowledge, aren't clear about indexing things that aren't nested.
MongoDB automatically creates a multikey index if any indexed field is an array; you do not need to explicitly specify the multikey type. Show activity on this post. The two sets of index creation commands you give in A are not equivalent. The first creates separate indexes on value and valuetwo .
In MongoDB, you can only nest document up to 100 levels. The overall document size must not exceed 16 MB.
MongoDB can use the intersection of multiple indexes to fulfill queries. In general, each index intersection involves two indexes; however, MongoDB can employ multiple/nested index intersections to resolve a query.
Yes, you can and it works: To index a field that holds an array value, MongoDB creates an index key for each element in the array. These multikey indexes support efficient queries against array fields.
You'd create them just as if you were creating an index on a top level field:
db.collection.createIndex({"attrs.nested.value": 1})
You do need to explicitly create indexes on each field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With