David
unread,Mar 5, 2011, 3:06:23 PM3/5/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.