Combining $all with other expressions

6 views
Skip to first unread message

David

unread,
Mar 5, 2011, 3:06:23 PM3/5/11
to mongodb-user
Hi,

I'm trying to understand the behavior of expressions like $in, $gt and
$lt when combined with $all.

Example:
Having these 9 documents:
{ n: 1, x: ["a","a"] }
{ n: 2, x: ["a","b"] }
{ n: 3, x: ["a","c"] }
{ n: 4, x: ["b","a"] }
{ n: 5, x: ["b","b"] }
{ n: 6, x: ["b","c"] }
{ n: 7, x: ["c","a"] }
{ n: 8, x: ["c","b"] }
{ n: 9, x: ["c","c"] }

When I run db.x.find({x:{ $in: ["a","b"] }}); I get all the documents
having "a" or "b" as values of the x array, so I get 8 documents (just
the 9th document is excluded).

When I run db.x.find({x:{ $all: ["c"] }}); I get all the documents
having "c" as value of the x array, so I get 5 documents (the 3, 6, 7,
8 and 9).

When I run db.x.find({x:{ $in: ["a","b"], $all: ["c"] }}); I'm
expecting to have all the documents having "a" or "b" as values and
having "c" as value (the 3, 6, 7 and 8) - the intersection of both
queries. Instead, I get nothing.

Can anyone explain me what's happening on background to generate this
empty query result?
Thank you.

Eliot Horowitz

unread,
Mar 6, 2011, 3:01:06 AM3/6/11
to mongod...@googlegroups.com
This looks like a bug.
Can you open a case @ http://jira.mongodb.org/

> --
> 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.
>
>

Reply all
Reply to author
Forward
0 new messages