cannot do $elemMatch query on array index field in mongodb 2.4

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.4.9
    • Component/s: Querying
    • Environment:
    • ALL
    • Hide

      2.4.9-pre-

      > db.c.insert({a:[[{b:3}]]})
      > db.c.find({"a.0":{$elemMatch:{b:3}}})
      > // nothing was returned
      

      2.5.4-pre-

      > db.c.insert({a:[[{b:3}]]})
      > db.c.find({"a.0":{$elemMatch:{b:3}}})
      { "_id" : ObjectId("5286b36c89a3f0da8275dca9"), "a" : [  [  {  "b" : 3 } ] ] }
      
      Show
      2.4.9-pre- > db.c.insert({a:[[{b:3}]]}) > db.c.find({ "a.0" :{$elemMatch:{b:3}}}) > // nothing was returned 2.5.4-pre- > db.c.insert({a:[[{b:3}]]}) > db.c.find({ "a.0" :{$elemMatch:{b:3}}}) { "_id" : ObjectId( "5286b36c89a3f0da8275dca9" ), "a" : [ [ { "b" : 3 } ] ] }
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Query behavior discrepancy: In version 2.4 of MongoDB, there's no support for doing an $elemMatch on an index of an array field. This is supported in 2.5, however. Intuitively, the 2.5 behavior seems correct, which could mean 2.4 should be updated or this change in behavior should have some documentation (and this ticket can be moved to DOCS).

            Assignee:
            Unassigned
            Reporter:
            Luke Lovett (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: