# Atlas Search index
## Create the index
Atlas UI: Search tab, Create Search Index, JSON editor. Or via driver/CLI:
```js
db.products.createSearchIndex("default", {
mappings: { dynamic: true }
});
```
`dynamic: true` indexes everything with default analyzers: fine for starting, wasteful at scale. For production, define explicit mappings:
```js
db.products.createSearchIndex("product_idx", {
mappings: {
dynamic: false,
fields: {
name: { type: "string", analyzer: "lucene.standard" },
description: { type: "string", analyzer: "lucene.english" },
price: { type: "number" }
}
}
});
```
## Query
```js
db.products.aggregate([
{ $search: {
index: "product_idx",
text: { query: "wireless headphones", path: ["name", "description"] }
} },
{ $limit: 10 },
{ $project: { name: 1, score: { $meta: "searchScore" } } }
]);
```
## Rules
- The index type here is `search`, not `vectorSearch`. They are different indexes for different query operators (`$search` vs `$vectorSearch`).
- Pick analyzers per field language: the english analyzer stems ("running" matches "run"); standard does not. Wrong analyzer = missed results.
- Index builds are async; poll until READY before querying.
- `$search` must be the first stage, like `$vectorSearch`.
## Verify
A query for a known term returns the known document at the top with a `searchScore`, and an explain on the query shows the search index in use.