Prompt
MongoDB Atlas Search query tuning problems
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
If you’re having MongoDB Atlas Search query tuning problems, the main things to inspect are usually:
-
Analyzer choice
- Are you using the right analyzer for the field type and search behavior?
- Example:
autocompletefor prefix search,standard/lucene.standardfor general text, keyword-like analyzers for exact matches.
-
Index mapping
- Verify fields are indexed with the correct type (
string,autocomplete,number,date, etc.). - If a field isn’t mapped correctly, queries may be slow or return unexpected results.
- Verify fields are indexed with the correct type (
-
Using the right operator
textfor full-text searchautocompletefor typeaheadequalsfor exact matchrangefor numeric/date filteringcompoundto combine must/should/filter logic efficiently
-
Scoring vs filtering
- Put non-relevance constraints in
filterinstead ofmustwhen possible. filteris cheaper because it doesn’t affect score.
- Put non-relevance constraints in
-
Facet / sort / pagination costs
- Sorting on large unindexed fields or deep pagination can be expensive.
- Prefer using a stable sort field and avoid large
skipvalues if possible.
-
Result shaping
- Limit returned fields with
$projectto reduce payload size. - Use
highlightonly when needed; it adds overhead.
- Limit returned fields with
-
Index size and field selection
- Don’t index unnecessary fields.
- Large documents or many indexed fields can degrade performance.
-
Explain plans and profiling
- Use Atlas Search explain output and MongoDB profiler to see where time is spent.
- Check whether the bottleneck is search, filtering, sorting, or network transfer.
A good tuning pattern is often:
- narrow candidates with
filter - use
mustfor relevance - avoid expensive post-processing
- index only what you need
- validate with
explain
If you want, I can help more specifically if you share:
- your index definition
- the search query
- approximate collection size
- what’s wrong: slow, low recall, bad ranking, or high cost