I am using version 2.6.1. I am trying to create a text index and I'm getting error:
{
"connectionId" : 4932,
"err" : "language override unsupported: en-US",
"code" : 17262,
"n" : 0,
"ok" : 1
}
The documents being searched have a "language" field that has a value of "en-US", but it is not used to override the language in a text search. I tried to create the text index to specify a field that doesn't exist ("lang"); however, I get the same error. I was able to create the index just fine on version 2.6.0. Is there a way to create the text index and ignore the language_override field?
Here is the working command I used on 2.6.0 (doesn't work on 2.6.1):
db.collection.ensureIndex({ title: "text" }, { name: "TextIndex" })
Here is the command I tried on 2.6.1 to specify another language_override field that does not exist:
db.collection.ensureIndex({ title: "text" }, { name: "TextIndex" }, { language_override: "lang" })
Thanks in advance!
Set the default_language
and language_override
to the same literal value (in your case "en").
I hit the same problem, also on Mongo 2.6.1.
In my case I created the index with a language_override
pointing to a language field where there were already documents with unsupported values (e.g. 'ar' - Arabic).
Here's 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 it would fall back to the default_language
when the language_override
value is unsupported, but apparently not. Here's what Mongo says:
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 3,
"ok" : 0,
"errmsg" : "language override unsupported: ar",
"code" : 17262
}
OK, fine, so the index wasn't created but I should be able to create it without the language_override, right? Wrong - mongo gives me the same error even though I no longer have the language_override specified.
The failed attempt at creating the index seems to have left behind some broken version of the index that does not show up anywhere so I can't drop it (it doesn't appear in db.users.getIndexes()
and dropping it by name doesn't work).
In the end I managed to fix the index by setting the language_override
to the 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 Mongo replies:
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 3,
"numIndexesAfter" : 4,
"ok" : 1
}
Hurrah.
The value "en-US" is illegal as a language for text indexing according to doc page http://docs.mongodb.org/manual/reference/text-search-languages/#text-search-languages
MongoDB accepts only a 2 letter code or full name of language.
Hope it helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With