Index
Functions for Index
Creates an index on this collection.
Get information on collections’s indexes
Drops the specified index on this collection
To drop all indexes on this collection, use drop_indexes()
Compound Index
Create indexes on more than one field.
PyMongo에서 가독성을 위해 값을 제공하고 있다. 아래는 같은 뜻으로 이해하면 되겠다.
pymongo.ASCENDING = 1, pymongo.DESCENDING = -1
Indexing on Embedded Document
Indexes can be created on keys in embedded documents.
Indexing to Array
Unique & Sparse Index
Unique indexes guarantee that each value will appear at most once in the index
Sparse indexes only contain entries for documents that have the indexed field skipping documents without it.
Unique & Sparse
Hint
To override MongoDB’s default index selection and query optimization process.
collection.find().sort([('key_4', 1)]).hint([('key_4', 1)])
Geospatial Index
Type
pymongo.GEO2D ==> 2d
pymongo.GEOSPHERE ==> 2dsphere
Example
Text Index
Create a text index on one field
Create text indexes on multiple fields
Specify the weight of an indexed
Last updated