[SERVER-12860] Index on sub-document in _id Created: 24/Feb/14  Updated: 23/Mar/14  Resolved: 23/Mar/14

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.5.5
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Dr. Markus Schmidberger Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 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



 Comments   
Comment by Dr. Markus Schmidberger [ 20/Mar/14 ]

Ok, we now use a consistent order of the subdocuments. You can close this issue.

Comment by Eliot Horowitz (Inactive) [ 24/Feb/14 ]

Is there a reason you can't use a consistent order for the subdocuments?
All drivers expose methods to do so.

Generated at Thu Feb 08 03:29:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.