Mongodb:使用排序规则将索引替换为相同的索引

时间:2018-04-25 09:25:32

标签: mongodb

test1上有索引的大型合约field。它没有整理。

db.test1.createIndex({field: 1});

我需要使用collat​​ion:

将此索引替换为相同的索引
db.test1.createIndex({field: 1}, {collation: {locale: "en_US", strength: 2}})
{ 
    "ok" : 0.0, 
    "errmsg" : "An index with the same key pattern, but a different collation already exists with the same name.  Try again with a unique name. Existing index: { v: 2, key: { field: 1.0 }, name: \"field_1\", ns: \"test.test1\" } Requested index: { v: 2, key: { field: 1.0 }, name: \"field_1\", ns: \"test.test1\", collation: { locale: \"en_US\", caseLevel: false, caseFirst: \"off\", strength: 2, numericOrdering: false, alternate: \"non-ignorable\", maxVariable: \"punct\", normalization: false, backwards: false, version: \"57.1\" } }", 
    "code" : 85.0, 
    "codeName" : "IndexOptionsConflict"
}

需要删除旧索引并添加新索引。问题是应用程序总是需要索引

0 个答案:

没有答案