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

Index on sub-document in _id

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.5.5
    • Shell
    • None

    Description

      Hi,

      we have a database design with a sub-document in the _id field. Now we have the problem the the field order matters (compare documentation http://docs.mongodb.org/manual/core/index-single/#indexes-on-subdocuments) and the following example:

      db.test.insert({"_id":{"uid":1, "city":"Munich"}})
      db.test.insert({"_id":{"uid":2, "city":"Munich"}})
      db.test.insert({"_id":{"uid":3, "city":"Munich"}})
      db.test.insert({"_id":{"uid":2, "city":"Frankfurt"}})
      > db.test.find({"_id":{"uid":2, "city":"Munich"}})
      { "_id" :

      { "uid" : 2, "city" : "Munich" }

      }
      >
      > db.test.find({"_id":{"city":"Munich", "uid":2 }})
      NO RESULT

      What is the best solution to solve our issue? Do we have to redesign our complete data structure?

      Thanks a lot
      Markus

      Attachments

        Activity

          People

            Unassigned Unassigned
            markus.schmidberger@comsysto.com Dr. Markus Schmidberger
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: