During the first run with the new index everything works fine, the index is created and no error occurs.
On every subsequent start however, the application crashes with the following error:
Mongo(Error { kind: CommandError(CommandError { code: 27, code_name: "IndexNotFound", message: "index not found with name [_fts_0__ftsx_1]", labels: [] }), labels: [] })
This happens because MongoDB creates the text index over the keys _fts and _ftsx.
During the synchronization step of wither, the index is now "unknown" and wither tries to drop it, resulting in the above error since the index isn't named _fts_0__ftsx_1 but instead is actually called title_0.
As of right now, the only way to avoid this crash is to remove the Model::sync call of the struct.
This pull request makes wither prefer IndexModel.options.name over the generate_index_name_from_keys function.
If however, for some reason, IndexModel.options.name isn't set it defaults back to the generate_index_name_from_keys function.
Defining a struct with a text index causes the application to crash.
During the first run with the new index everything works fine, the index is created and no error occurs. On every subsequent start however, the application crashes with the following error:
Mongo(Error { kind: CommandError(CommandError { code: 27, code_name: "IndexNotFound", message: "index not found with name [_fts_0__ftsx_1]", labels: [] }), labels: [] })
This happens because MongoDB creates the text index over the keys
_fts
and_ftsx
. During the synchronization step of wither, the index is now "unknown" and wither tries to drop it, resulting in the above error since the index isn't named_fts_0__ftsx_1
but instead is actually calledtitle_0
. As of right now, the only way to avoid this crash is to remove theModel::sync
call of the struct.This pull request makes wither prefer IndexModel.options.name over the
generate_index_name_from_keys
function. If however, for some reason, IndexModel.options.name isn't set it defaults back to thegenerate_index_name_from_keys
function.