## TL;DR

The $vectorSearch aggregation stage is Atlas-only; running it against local MongoDB raises the '$vectorSearch is only valid for Atlas' error, so update the connection string to the Atlas cluster. Index Building Failed has three usual causes: the cluster tier must be M10 or higher for full Vector Search, the cluster version must be 6.0.11+ or 7.0.2+, and the collection needs at least one document.

## Fix

1. The $vectorSearch aggregation stage is Atlas-only; running it against local MongoDB raises the '$vectorSearch is only valid for Atlas' error, so update the connection string to the Atlas cluster.
   Expected: You get the expected result; the problem is gone.

## When to use

- You are setting up or using this MongoDB Atlas Vector Search feature.
- The symptom matches: '$vectorSearch is only valid for Atlas'.

## When NOT to use

- Unrelated MongoDB Atlas Vector Search issues (different feature, different failure).
- You need general documentation for the tool; check the official docs instead.

## Compatibility

Reported against MongoDB Atlas Vector Search (mentions 6.0.11, 7.0.2). Source: a local/non-public address.com/luvadlamudi/tamuhack26/blob/HEAD/backend/rag/VECTOR_INDEX_SETUP.md.

## Variant phrasings

### '$vectorSearch is only valid for Atlas'

## Why it happens

Pointing a vector-search app at a local or self-hosted MongoDB fails at runtime. The stage only exists on Atlas.

## Edge cases

- If your error message differs even slightly, this is probably a different issue; search the exact text.
- Behavior can change between releases; the linked source reflects the versions above.
- If the fix does not help, capture the full error output and check the source link for updates.

## Source

a local/non-public address.com/luvadlamudi/tamuhack26/blob/HEAD/backend/rag/VECTOR_INDEX_SETUP.md