I have a flask API and I am saving the data in MongoDB with the help of mongoengine and now I need to update the index programmatically. I don’t want to end up creating a new index each and every time instead I want to update the index with a particular name.
I don’t think it’s documented, but mongoengine’s create_index method takes a kwargs argument that I believe are just passed on to pymongo under the hood. This means if you want to specify the name for your index, you should be able to with a name keyword argument, as documented in the PyMongo docs.
I don’t use mongoengine myself, but I believe it should look something like this: