【发布时间】:2017-09-05 13:57:48
【问题描述】:
我在 f1, f2 和 db.test.createIndex({"f1":"text","f2":"text"},{unique:true}) 的两个字段上创建了索引
{
"v" : 2,
"unique" : true,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"name" : "f1_text_f2_text",
"ns" : "test.test",
"weights" : {
"f1" : 1,
"f2" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 3
}
当我插入两个文档时
db.test.insert({f1:"hello",f2:"there"})
db.test.insert({f1:"hello",f2:"there2"})
我收到重复键错误
"E11000 duplicate key error collection: test.test index: f1_text_f2_text dup key: { : \"hello\", : 1.1 }"
但是db.test.insert({f1:"hello2",f2:"there"}) 有效。
复合文本索引不应该像常规复合索引那样工作吗?
【问题讨论】: