Best practice question about setting Mongo indexes. Mongoengine, the Python ORM wrapper, allows you to set indexes in the Document meta class.
When is this meta class introspected and the index added? Can I build a collection via a mongoengine Document class and then add an index after the fact?
If I remove the index from the meta class, is the index automatically removed from the corresponding collection?
Thanks,
You can add an index at any time and
ensureIndexwill be called behind the scenes so it will be added if it doesn’t exist.If you remove an index from the meta – you will have to use pymongo or the shell to remove the index.