Index on sub-document in _id

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.5.5
    • Component/s: Shell
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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

            Assignee:
            Unassigned
            Reporter:
            Dr. Markus Schmidberger
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: