[ACCEPTED]-MongoDB Text Index Error: language override not supported-mongodb

Accepted answer
Score: 21

Solution:

Set the default_language and language_override to the same literal value 20 (in your case "en").

How I got here...

I hit the same problem, also 19 on Mongo 2.6.1.

In my case I created the 18 index with a language_override pointing to a language field 17 where there were already documents with 16 unsupported values (e.g. 'ar' - Arabic).

Here's 15 how I was creating the index:

db.users.ensureIndex({ 
  "displayName": "text", 
  "about": "text", 
  "email": "text" 
}, { 
  "name": "users_full_text", 
  "default_language": "en",
  "language_override": "language"
});

I was hoping 14 it would fall back to the default_language when the language_override value 13 is unsupported, but apparently not. Here's 12 what Mongo says:

{
  "createdCollectionAutomatically" : false,
  "numIndexesBefore" : 3,
  "ok" : 0,
  "errmsg" : "language override unsupported: ar",
  "code" : 17262
}

OK, fine, so the index wasn't 11 created but I should be able to create it 10 without the language_override, right? Wrong 9 - mongo gives me the same error even though I no longer have the language_override specified.

The failed 8 attempt at creating the index seems to have 7 left behind some broken version of the index 6 that does not show up anywhere so I can't 5 drop it (it doesn't appear in db.users.getIndexes() and dropping 4 it by name doesn't work).

In the end I managed 3 to fix the index by setting the language_override to the 2 literal value 'en', like this:

db.users.ensureIndex({ 
  "displayName": "text", 
  "about": "text", 
  "email": "text" 
}, { 
  "name": "users_full_text", 
  "default_language": "en",
  "language_override": "en" 
});  

... to which 1 Mongo replies:

{
  "createdCollectionAutomatically" : false,
  "numIndexesBefore" : 3,
  "numIndexesAfter" : 4,
  "ok" : 1
}

Hurrah.

Score: 5

The value "en-US" is illegal as 4 a language for text indexing according to 3 doc page http://docs.mongodb.org/manual/reference/text-search-languages/#text-search-languages

MongoDB accepts only a 2 letter 2 code or full name of language.

Hope it helps 1 :)

More Related questions