Mongodb Index is working but getplancache list is empty

I created an index on a nested field (items.type) in my MongoDB collection, and my query is using the index successfully (confirmed via IXSCAN in explain(“executionStats”)). However, when I check the query plan cache using:

db.collection.getPlanCache().list()

it returns an empty list. I expected MongoDB to cache the query plan, but its not appearing
I have tried running the query multiple times

Trying running your query with explain

db.collection.find({ "items.type": "example" }).explain("allPlansExecution")

Also be aware that if your query has only one possible plan, MongoDB skips caching… that might be the issue.

Try a more complex query (e.g., with sorting) to force cache usage… think this might give you the results you’re after.