But still need to know few more points about the restrictions in wild card index
I have created wild card index for the whole document like
“db.collection.createIndex({”$**:1"})
When I tried to check its executionPlan I found the following results
For all aggregate queries having $unwind in that query
Index keys are not examined
Always COLLSCAN is executed
From the above experiment I could observe that for any aggregate queries wild card will not work. Is my understanding correct. If yes can someone explain the above behavior?
For aggregations there are specific restrictions. However, if you want the aggregation to use the index you need to perform either a $match or $sort stages in the beginning of the query.
If you are starting your aggregation with the $unwind stage the aggregation will not be able to utilise an index and will unfold everything with collscan and memory operations.