Docs Menu
Docs Home
/ / /
PyMongo
/ /

Wildcard Indexes

On this page

  • Overview
  • Sample Data
  • Create a Wildcard Index

Wildcard indexes enable queries against unknown or arbitrary fields. These indexes can be beneficial if you are using a dynamic schema.

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.

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.

Back

Unique