Working with Text Indexes

1. Creating Text Index

FormEffect
createIndex({title: "text"})Single-field text index
LimitOne text index per collection

2. Creating Compound Text Index

FormEffect
createIndex({title:"text", body:"text"})Multi-field text
Wildcard{"$**":"text"} indexes all string fields

3. Setting Text Index Weights

AspectDetail
Option{ weights: { title: 10, body: 1 } }
EffectMultiplies term score per field
Default weight1

4. Setting Default Language

OptionEffect
default_languageStemming/stop-word language (e.g., "english", "spanish")
"none"Disables stemming and stop words

5. Using Language Override

OptionEffect
language_overrideField name holding per-doc language (default "language")
UseMulti-lingual content in one collection

6. Creating Wildcard Text Index

FormEffect
createIndex({"$**": "text"})Indexes all string fields
CostLarger index; slower writes

7. Dropping Text Index

FormNote
dropIndex("title_text")Default name pattern
getIndexes()Confirm exact name

8. Understanding Text Index Limitations

LimitationDetail
One per collectionCannot have two text indexes
No phrase fuzzinessUse Atlas Search for fuzzy
No prefix wildcardUse Atlas Search autocomplete
Cannot hint$text queries always use text index