Hi @cosmonaut13 and welcome to MongoDB community forums!!
Thank you for reporting the issue and the concern has been reported internally.
By default, which creating the text index, the default_language is set is nothing is specified while creating the index.
If you wish to use the same query in the example attached in the documentation, you can create index with the default_lauguage specified.
You can refer to the example below:
Atlas atlas-xp4gev-shard-0 [primary] test> db.quotes.createIndex( { original: "text", "translation.quote": "text"} ,{ "default_language": "fr"} )
original_text_translation.quote_text
Atlas atlas-xp4gev-shard-0 [primary] test> db.quotes.find( { $text: { $search: "réalité" } } )
[
{
_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é."
}
]
}
]
However, if you do not wish to create index with language specified, you would have to use the search query 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é."
}
]
}
]