Details

    • Type: Bug Bug
    • Status: In Progress In Progress
    • Priority: Major - P3 Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 1.5.2
    • Fix Version/s: 2.7 Desired
    • Component/s: Querying
    • Labels:
    • Backport:
      No
    • Backward Breaking:
      Rarely
    • Operating System:
      ALL
    • # Replies:
      11
    • Last comment by Customer:
      true
    • Driver changes needed?:
      No driver changes needed

      Description

      Here a test-case:

      > db.test.insert(

      {"field": [[100,300],[100, 110]]}

      )
      > db.test.findOne()

      { "_id" : ObjectId("4c1f229882c620b16f0d3fbd"), "field" : [ [ 100, 300 ], [ 100, 110 ] ] }

      These two commands should find this element but they don't:

      > db.test.find({"field": {$elemMatch:

      {0: 100, 1:300}

      }})
      > db.test.find({"field": {$elemMatch: {0: {$gt: 1}, 1: {$gt: 1}}}})

      1. server1264.js
        0.8 kB
        Benety Goh

        Issue Links

          Activity

          Hide
          auto
          added a comment -

          Author:

          {u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

          Message: SERVER-1264 update test
          Branch: master
          https://github.com/mongodb/mongo/commit/5410320e7c70616f3321f76859f8575a68230dd3

          Show
          auto
          added a comment - Author: {u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'} Message: SERVER-1264 update test Branch: master https://github.com/mongodb/mongo/commit/5410320e7c70616f3321f76859f8575a68230dd3
          Hide
          Aaron Staple (Inactive)
          added a comment -

          Robert identified some additional todos for supporting the full range of mongo query operators inside $elemMatch. He described them in SERVER-5506.

          Show
          Aaron Staple (Inactive)
          added a comment - Robert identified some additional todos for supporting the full range of mongo query operators inside $elemMatch. He described them in SERVER-5506 .
          Hide
          auto
          added a comment -

          Author:

          {u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

          Message: SERVER-4180 Fixes and cleanups for $elemMatch index range calculation, in particular to clean up incorrect bound generation for SERVER-1264 style $elemMatch queries. Includes fixes for SERVER-5740 and SERVER-5741.
          Branch: master
          https://github.com/mongodb/mongo/commit/2b572b9c07d8d3feda949153e20b9eee8706ff7d

          Show
          auto
          added a comment - Author: {u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'} Message: SERVER-4180 Fixes and cleanups for $elemMatch index range calculation, in particular to clean up incorrect bound generation for SERVER-1264 style $elemMatch queries. Includes fixes for SERVER-5740 and SERVER-5741 . Branch: master https://github.com/mongodb/mongo/commit/2b572b9c07d8d3feda949153e20b9eee8706ff7d
          Hide
          auto
          added a comment -

          Author:

          {u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

          Message: SERVER-4180 Generate single key index bounds for $elemMatch expressions of the SERVER-1264 style (where matching is applied to the $elemMatch field itself, not subfields).
          Branch: master
          https://github.com/mongodb/mongo/commit/bb0fd337ac9498a5642986bba162880fa3030ce0

          Show
          auto
          added a comment - Author: {u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'} Message: SERVER-4180 Generate single key index bounds for $elemMatch expressions of the SERVER-1264 style (where matching is applied to the $elemMatch field itself, not subfields). Branch: master https://github.com/mongodb/mongo/commit/bb0fd337ac9498a5642986bba162880fa3030ce0
          Hide
          Thomas Zahn
          added a comment -

          As a consequence, this unfortunately also affects the work-around to detect instances where a field a is an array, as suggested in SERVER-1475:

          db.test1.find({$or: [{"a": {$size: 0}}, {"a": {$elemMatch: {$exists: true}}}]})
          

          It won't work for nested arrays.

          mongos> db.test1.find()
          { "_id" : ObjectId("52fcf0e3f067bdb1472ebeef"), "a" : [  7,  10 ] }
          { "_id" : ObjectId("52fcf0e3f067bdb1472ebef0"), "a" : [  1,  2,  3 ] }
          { "_id" : ObjectId("52fcf0e3f067bdb1472ebef1"), "a" : [  [  10,  11 ],  [  20,  21 ] ] }
          { "_id" : ObjectId("52fcf0e3f067bdb1472ebef2"), "a" : [  [  1 ],  [  2 ],  [  3 ] ] }
          { "_id" : ObjectId("52fcf0e3f067bdb1472ebef3"), "a" : [  [ ] ] }
          

          Suppose one now wanted to explicitly find those documents where a specific element of a (e.g. a.0) is again an array, i.e. a 2-dimensional array. Unfortunately, only $size seems to work on a.0, whereas $elemMatch fails:

          mongos> db.test1.find({$or: [{"a.0": {$size: 0}}, {"a.0": {$elemMatch: {$exists: true}}}]})
          { "_id" : ObjectId("52fcf0e3f067bdb1472ebef3"), "a" : [  [ ] ] }
          mongos> db.test1.find({"a.0": {$size: 0}})
          { "_id" : ObjectId("52fcf0e3f067bdb1472ebef3"), "a" : [  [ ] ] }
          mongos> db.test1.find({"a.0": {$elemMatch: {$exists: true}}})
          mongos>
          
          Show
          Thomas Zahn
          added a comment - As a consequence, this unfortunately also affects the work-around to detect instances where a field a is an array, as suggested in SERVER-1475 : db.test1.find({$or: [{"a": {$size: 0}}, {"a": {$elemMatch: {$exists: true}}}]}) It won't work for nested arrays. mongos> db.test1.find() { "_id" : ObjectId("52fcf0e3f067bdb1472ebeef"), "a" : [ 7, 10 ] } { "_id" : ObjectId("52fcf0e3f067bdb1472ebef0"), "a" : [ 1, 2, 3 ] } { "_id" : ObjectId("52fcf0e3f067bdb1472ebef1"), "a" : [ [ 10, 11 ], [ 20, 21 ] ] } { "_id" : ObjectId("52fcf0e3f067bdb1472ebef2"), "a" : [ [ 1 ], [ 2 ], [ 3 ] ] } { "_id" : ObjectId("52fcf0e3f067bdb1472ebef3"), "a" : [ [ ] ] } Suppose one now wanted to explicitly find those documents where a specific element of a (e.g. a.0 ) is again an array, i.e. a 2-dimensional array. Unfortunately, only $size seems to work on a.0 , whereas $elemMatch fails: mongos> db.test1.find({$or: [{"a.0": {$size: 0}}, {"a.0": {$elemMatch: {$exists: true}}}]}) { "_id" : ObjectId("52fcf0e3f067bdb1472ebef3"), "a" : [ [ ] ] } mongos> db.test1.find({"a.0": {$size: 0}}) { "_id" : ObjectId("52fcf0e3f067bdb1472ebef3"), "a" : [ [ ] ] } mongos> db.test1.find({"a.0": {$elemMatch: {$exists: true}}}) mongos>

            People

            • Votes:
              8 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since reply:
                8 weeks, 6 days ago
                Date of 1st Reply: