Explain plan for Atlas search

I have created a M0 cluster in Mongo Atlas. Im running atlas search on a collection I have created. I would like to run explain plan for the search query to know the time taken to execute. db.collection.explain().aggregate() is working without any error. But when running
db.collection.explain(“executionStats”).aggregate(), there is a error as below
“ok” : 0,
“errmsg” : “(Unauthorized) not authorized on demoecommerce to execute command { aggregate: “inventory”, pipeline: [[{$search [{index inv_idx} {text [{query JBL} {path productName}]}]}] [{$project [{_id 0} {productName 1}]}]], cursor: { } }”,
“code” : 8000,
“codeName” : “AtlasError”

Please let me know how can I run explain plan for atlas search or if there is any other option to get the time take for execution in atlas search.

Issue confirmed on my end.

MongoDB Enterprise Free-shard-0:PRIMARY> db.zips.explain().aggregate([{"$match": {city: "NEW YORK"}}])
	"queryPlanner" : {
		"plannerVersion" : 1,
		"namespace" : "5e9099160ff7e0434fe7c98c_sample_training.zips",
		"indexFilterSet" : false,
		"parsedQuery" : {
			"city" : {
				"$eq" : "NEW YORK"
		"queryHash" : "0491F17A",
		"planCacheKey" : "0491F17A",
		"optimizedPipeline" : true,
		"winningPlan" : {
			"stage" : "COLLSCAN",
			"filter" : {
				"city" : {
					"$eq" : "NEW YORK"
			"direction" : "forward"
		"rejectedPlans" : [ ]
	"serverInfo" : {
		"host" : "atlas-8vl55a-shard-00-01.ruudt.mongodb.net",
		"port" : 27000,
		"version" : "4.2.8",
		"gitVersion" : "43d25964249164d76d5e04dd6cf38f6111e21f5f"
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1599050624, 1),
		"signature" : {
			"hash" : BinData(0,"u5KzhKzaKG/yBSkDRg4/zS2OmrI="),
			"keyId" : NumberLong("6813510425880035331")
	"operationTime" : Timestamp(1599050624, 1)
MongoDB Enterprise Free-shard-0:PRIMARY> db.zips.explain(true).aggregate([{"$match": {city: "NEW YORK"}}])
uncaught exception: Error: explain failed: {
	"ok" : 0,
	"errmsg" : "(Unauthorized) not authorized on sample_training to execute command { aggregate: \"zips\", pipeline: [[{$match [{city NEW YORK}]}]], cursor: {  } }",
	"code" : 8000,
	"codeName" : "AtlasError"
} :

I don’t see this documented in:

I escalated this conversation to the Atlas team. I’m waiting for an answer at the moment.

That being said - there is probably a reason for this operation to not be supported on shared environment and I don’t have this issue with an M10 cluster.

1 Like

We have not released explain plans yet for the $search stage yet, but they are in active development and will be released soon.

Hi Durga_Krishnamoorthi,
I’m a product manager at MongoDB and work with the team that built and maintains a large part of the M0/2/5 stack. I’ve verified that the explain() behavior you reported above is a bug and we now have it in our list to fix. Very much appreciate you taking the time to ask and provide details around the issue as it really helps us ensure you have the best experience possible!

Thank you,
Melissa Plunkett


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.