Support flexible queries on unknown or varying fields.
Section: MongoDB index types
Wildcard index
javascript
javascript
db.events.createIndex({ "$**": 1 })Explanation
Wildcard indexes can help when documents contain highly variable keys, though they should be used carefully.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing MongoDB index types
Multikey index on an array field
Index documents that contain array values.
Explain a query with execution stats
Inspect planner and runtime behavior.