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

Compound index using array indexes doesn't return query results

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL

      This is definitely an edge case, but probably should work (referenced here: http://groups.google.com/group/mongodb-user/browse_thread/thread/32511a51caad9085). Here's how to reproduce:

      > db.a.save({a: {spec: [{ info: [

      {key: "author", value: "poe"}

      ]} ]}})
      > db.a.find()
      { "_id" : ObjectId("4e5d23ba339dc0b7074165f6"), "a" : { "spec" : [ { "info" : [

      { "key" : "author", "value" : "poe" }

      ] } ] } }

      > db.a.find(

      {"a.spec.0.info.0.key": "author", "a.spec.0.info.0.value": "poe"}

      )
      { "_id" : ObjectId("4e5d23ba339dc0b7074165f6"), "a" : { "spec" : [ { "info" : [

      { "key" : "author", "value" : "poe" }

      ] } ] } }

      So far so good. Now add an index:
      > db.a.ensureIndex(

      {"a.spec.0.info.0.key": 1, "a.spec.0.info.0.value": 1}

      )

      > db.a.find(

      {"a.spec.0.info.0.key": "author", "a.spec.0.info.0.value": "poe"}

      )
      Returns nothing!

            Assignee:
            Unassigned Unassigned
            Reporter:
            kbanker Kyle Banker
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: