MongoDB "$search ... Atlas Search is not available" against local mongod in CI
The $search aggregation stage is an Atlas Search feature backed by a separate search process. A local or service-container mongod has no Atlas Search, so $search fails there even though it works against your Atlas cluster.
What this error means
An aggregation using $search fails against a local/CI mongod with "$search is not allowed in this context" or "Unrecognized pipeline stage name: '$search'", but succeeds on Atlas.
MongoServerError: $search is not allowed or the syntax is incorrect,
see the Atlas documentation for more information
code: 40324, codeName: 'Location40324'Common causes
Local mongod has no Atlas Search
Atlas Search runs as a managed search node alongside Atlas; a standalone mongod in CI cannot execute $search.
Tests point at the local service instead of Atlas
The suite uses $search but the CI URI targets a local mongod without search, so the stage is rejected.
How to fix it
Run search tests against Atlas or a local Atlas Search deployment
- For $search coverage, point those tests at an Atlas cluster with a search index.
- Or use the Atlas CLI local deployment, which includes Atlas Search.
- Keep plain data tests on the fast local mongod.
atlas deployments setup local --type local
atlas deployments search indexes create --deploymentName local ...Skip or gate $search tests without Atlas
Guard search-only tests so they are skipped when the target is a plain mongod, and run them on the Atlas-backed job.
How to prevent it
- Route $search tests to an Atlas-backed target.
- Use the Atlas CLI local deployment when you need search offline.
- Gate Atlas-only features so local runs do not fail on them.