-
Type:
Task
-
Resolution: Done
-
Priority:
Minor - P4
-
Affects Version/s: None
The example in the documentation https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/specify-language-text-index/create-text-index-multiple-languages/#results needs to updated as the it does not contain information that the default_language is set to English by default.
If user wishes to use the example as given in the above doc, the index needs to be set as:
db.quotes.createIndex( { original: "text", "translation.quote": "text" , "default_language": "fr"} )
If the default_language is not specified, the query needs to be altered as:
Atlas atlas-xp4gev-shard-0 [primary] test> db.quotes.find( { $text: { $search: "réalité" , $language: "fr" }} ) [ { _id: 2, language: 'spanish', original: 'Nada hay más surrealista que la realidad.', translation: [ { language: 'english', quote: 'There is nothing more surreal than reality.' }, { language: 'french', quote: "Il n'y a rien de plus surréaliste que la réalité." } ] } ]