Docs Home → Develop Applications → Python Drivers → PyMongo
Wildcard Indexes
On this page
Overview
Wildcard indexes enable queries against unknown or arbitrary fields. These indexes can be beneficial if you are using a dynamic schema.
Sample Data
The examples in this guide use the sample_mflix.movies
collection
from the Atlas sample datasets. To learn how to create a
free MongoDB Atlas cluster and load the sample datasets, see the
Get Started with PyMongo.
Create a Wildcard Index
The following example creates an ascending wildcard index on all
values of the location
field, including values nested in subdocuments and arrays:
movies.create_index({ "location.$**": pymongo.ASCENDING })
For more information, see the Wildcard Indexes page in the MongoDB Server manual.