Missing 'winningPlan' while using 'explain()' with query in MongoDB

Hello Samrat,

The reason why the winningPlan field is not present in the output just so happens to be because the search index is being utilized exclusively. The only query stage to be explained is the query running against the mongot process, hence why the output of the first stage in the explain output is "$_internalSearchMongotRemote" . $search aggregation pipeline stages are executed against the mongotprocess, which is technically a Lucene index. So if you look at the fields $_internalSearchMongotRemote.mongotQuery.index you can specifically find the search indexes being used.

winningPlan is output from the mongod process query planner, which would only be observed in the output of .explain() for things like .find() and other .aggregate() pipeline stages that are not $search which need to query and fetch documents in a MongoDB collection, or utilize an index (not to be confused with a search index).

We could probably include something in our docs that better explains this, as currently there are two different docs for explain results that don’t really allude to the fact that different output can be expected when using $search exclusively.

Current docs:
Interpret Explain Plan Results

Search Explain

1 Like