Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-16530

The example needs to be updated or correct informations needs to be added

      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é."
            }
          ]
        }
      ]
       
      

       

            Assignee:
            caleb.thompson@mongodb.com Caleb Thompson
            Reporter:
            aasawari.sahasrabuddhe@mongodb.com Aasawari Sahasrabuddhe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              21 weeks, 5 days ago