Reputation: 1181
I have a large but simple collection in DocumentDB (3.6) and need to quickly and efficiently retrieve all document ids matching a simple regex pattern.
On the cli I can search for these with a regex and hint and seem to get good results via explain.
When I try to transfer this to a call from pymongo I get an error saying the index cannot be found... which is odd as its _id I'm hinting for and I can clearly see it defined on the cli.
Am I going crazy or is there no way to hint in pymongo when using DocumentDB?
How could I work around this issue if not possible? Does it make sense to go as far as calling the mongo cli from a system call within python (seems excessive...)?
Upvotes: 1
Views: 305
Reputation: 2708
Yes you should be able to use hint with pymongo. You can append hint to your find command -
collection.find({'name': 'foo'}).hint(index_name')
Upvotes: 1