pymongo: query mongo by object

18 views
Skip to first unread message

Jeff

unread,
Jun 27, 2016, 9:01:13 AM6/27/16
to mongodb-user
Hello,
having collection with compound _id field: {_id:{i:1, k:2}, data:"bar"}

// nothing found
collection.find_one({'_id':{"i" : 1, "k" : 2}})

// found, but slow, because index on _id object is not used
collection.find_one({"_id.i" : 1, "_id.k" : 2})


is this bug in pymongo? why the first query doesn't work otherwise?


Thanks
Jeff

Jeff

unread,
Jun 28, 2016, 6:12:30 AM6/28/16
to mongodb-user
it happens only on this specific collection. I've created test one with similar structure and it works fine there. Still have no idea why it doesn't work with the real data

Bernie Hackett

unread,
Jun 28, 2016, 1:47:03 PM6/28/16
to mongodb-user

why the first query doesn't work otherwise?


Reply all
Reply to author
Forward
0 new messages