Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2689

Inconsistent behavior when combining $all with other operators

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.6.5
    • Component/s: Index Maintenance, Querying
    • None
    • Environment:
      Linux 32bit, MongoDB 1.6.5
    • ALL

      When $all is combined with other operators (ie: $in, $gt, $lt), the results are not the expected.

      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"] }

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

      > db.x.find({x:{ $all: ["c"] }}); return all the documents
      having "c" as value of the x array, - 5 documents (the 3, 6, 7,
      8 and 9).

      > db.x.find({x:{ $in: ["a","b"], $all: ["c"] }}); should return 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, return nothing.

      mongodb-user theread: http://groups.google.com/group/mongodb-user/browse_thread/thread/4033cd8335f7261e

            Assignee:
            Unassigned Unassigned
            Reporter:
            doliveira David Oliveira
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: