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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 2.4.9
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
    • Environment:
    • Operating System:
      ALL
    • Steps To Reproduce:
      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 } ] ] }

      Description

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

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            luke.lovett Luke Lovett
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: