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+:

https://docs.atlas.mongodb.com/reference/atlas-search/tutorial

Thanks
Pavel

1 Like