Why isn't my reIndex command allowed in pymongo?

I was testing the pymongo error messages for reaching my storage quota, and this resulted in me creating a 177.96MB index for a 4.03MB collection (after deleting the dummy logs used to fill my quota). I’m trying to delete the excess index, but I’m repeatedly receiving this error.

OperationFailure: CMD_NOT_ALLOWED: reIndex, full error: {'ok': 0, 'errmsg': 'CMD_NOT_ALLOWED: reIndex', 'code': 8000, 'codeName': 'AtlasError'}

The MongoDB Role I’m using to access the cluster is atlasAdmin. So, I’m not sure why I wouldn’t have access to this command. I’m getting the error when running the following lines.

client.database_name.collection_name.drop_indexes()
client.database_name.command({'reIndex': 'collection_name'})

Does anyone know why I would be unable to do this?

Note:
Starting in MongoDB 4.6, the reIndex command can only be run when connected to a standalone mongod.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html

1 Like

Thanks for pointing that out. Any idea how I would remove the enormous index?

Well, you could just drop it and have a piece of code that recreates it, I think.