I have a text index on a collection. I added a language
field to my documents, and all of a sudden started receiving a bunch of "language override unsupported: <LANG>"
errors. Apparently language
is a magical field when you have a text index.
How do I make mongo not throw an error if the language is unsupported? It doesn't matter to me if a language is unsupported. I want my insert operation to succeed, regardless if the language is supported or not.
The insert operation:
// This should succeed regardless if suggestion.language is an unsupported language
// I don't want to wrap this in a try/catch, and have to retry on error.
addSuggestion (suggestion) {
const suggCol = db.get().collection('suggestions')
return suggCol.insertOne(suggestion)
},
How I create my index
// Create a text index, on the "text" property.
// TODO: Mongo throws error if suggestion.language contains an
// unsupported language. Override the language for now.
db.collection('suggestions').createIndex({ text: 'text' }, { language_override: 'dummyVal' })
To avoid the error for now, I'm ignoring the text index by setting { language_override: 'dummyVal' }
. In the future, I would like to use the language_override.
This is a feature and you seem to have already arrived at the correct solution - language_override
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.