MongoDB remove() function deletes documents but retains indexes I have came across in one of my readings that remove() function will delete the documents without any changes to the existing indexes. 

for instance: "db.users.remove() - This will remove all of the documents in the users collection. This doesn’t actually remove the collection, and any indexes created on it will still exist."

I would like to understand why the indexes are retained when the actual referenced data is removed / deleted in that specific collection? is there any specific use case?

Thank you
The db.collection.remove() command is used to remove data from a collection. As such, documents will be removed from the collection and the indexes on the collection will be updated to no longer reference the removed documents. 

Remove can be used in such a way to only remove a subset of data. From the docs:

db.products.remove( { qty: { $gt: 20 } } )


For example, you may want to remove a subset of data but retain the existing indexes to continue access the remaining data according to the existing access patterns. 

This command contrasts from the db.collection.drop() command, which removes the entire collection along with its indexes.