Syntax
Syntax
collection.create_index( [ (‘field’, TYPE) ] ) # Create Index collection.index_information() # Get Index Info collection.drop_index( [ (‘field’, TYPE) ] ) # Drop Index
Example for geospatial index
from pymongo import MongoClient, GEOSPHERE client = MongoClient() db = client.geo col = db.states col.create_index([("loc", GEOSPHERE)])
Last updated
Was this helpful?