Error Throwing Unrecognized pipeline stage name: '$search'

I am using MongoDB atlas search.

db.collection.aggregate([{
$search: {
	text: {
		query: 'multi word query',
		path: [...some fields],
	},
}}]);

It is always says…below error.

Error:

Uncaught exception: Error: command failed: {
	"ok" : 0,
	"errmsg" : "Unrecognized pipeline stage name: '$search'",
	"code" : 40324,
	"codeName" : "Location40324"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:583:17
assert.commandWorked@src/mongo/shell/assert.js:673:16
DB.prototype._runAggregate@src/mongo/shell/db.js:266:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1012:12
DBCollection.prototype.aggregate@:1:355
@(shell):1:1

Could you help to unblock.

Hi @Merlin_Baptista_B,

Welcome to MongoDB community

Have you created an atlas search index on that collection?

What is the atlas cluster version?

It is supported from 4.2+:

Thanks
Pavel

1 Like

I have the same problem, I have created search index on Atlas cloud via search UI (default search index for now)
How can I resolve this issue?

Problem solved. I was using local DB instead of the Atlas one

Check if you are looking at the right DB, on the local DB search can’t work as far as I understand