Optimize Queries with Indexes
Remove an Index
Remove a Single Index
movies.drop_index("_title_")
Remove All Indexes
collection.drop_indexes()
Single Field Index
result = collection.create_index("<field name>")
Compound Index
result = collection.create_index([
("<field name one>", pymongo.ASCENDING),
("<field name two>", pymongo.ASCENDING)
])
Unique Index
result = collection.create_index("<field name>", unique=True)
Remove an Index
collection.drop_index("<index_name>")