--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/BwuFYJicsfcJ.
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.
the issue arises when you use arrays:
1. Only one array element: index is "correctly" used
> db.foo.insert({aH: [ {s: 'x', m: 'y', u: 'z'} ] })
> db.foo.ensureIndex({'aH.s': 1, 'aH.m': 1, 'aH.u': 1})
> db.foo.find({'aH': { $elemMatch : {'s': 'x', 'm': 'y', 'u': 'z'}}}).explain()
{
"cursor" : "BtreeCursor aH.s_1_aH.m_1_aH.u_1",
"nscanned" : 1,
"nscannedObjects" : 1,
"n" : 1,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"aH.s" : [
[
"x",
"x"
]
],
"aH.m" : [
[
"y",
"y"
]
],
"aH.u" : [
[
"z",
"z"
]
]
}
}
2. One single element in the collection has two array elements. Only the first part of the index is used
> db.foo.insert({aH: [ {s: 'a1', m: 'b1', u: 'c1'}, {s: 'a2', m:'b2', u:'c2'}] })
> db.foo.find({'aH': { $elemMatch : {'s': 'x', 'm': 'y', 'u': 'z'}}}).explain()
{
"cursor" : "BtreeCursor aH.s_1_aH.m_1_aH.u_1",
"nscanned" : 1,
"nscannedObjects" : 1,
"n" : 1,
"millis" : 0,
"nYields" : 0,
"nChunkSkips" : 0,
> --
> 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.
>
--
Dominik Gehl
Lead Developer
http://context.io
@DominikGehl
> > For more options, visit this group athttp://groups.google.com/group/mongodb-user?hl=en.
Please see the updated comments in SERVER-4164.
Thanks,
Aaron
On Oct 27, 11:26 am, Bernie Hackett <ber...@10gen.com> wrote:
> This seems wrong to me. I openedhttps://jira.mongodb.org/browse/SERVER-4164.
thanks for the info. I'm going around the issue for now by creating a new field in each document, composed of the concatenation of aH.s, aH.m and aH.u and then indexing on that field.
Dominik
Dominik
--