I have a MongoDB(v 5.0.6) collection with the following data:
[{
"_id": {
"$oid": "63bc06e6aa310000d6004a68"
},
"key": "title",
"label": "title",
"type": "text",
"searchable": 0
},{
"_id": {
"$oid": "63bc06e6aa310000d6004a69"
},
"key": "attribution",
"label": "attribution",
"type": "text",
"searchable": 0
},{
"_id": {
"$oid": "63bc06e6aa310000d6004a6a"
},
"key": "description",
"label": "description",
"type": "text",
"searchable": 0
},{
"_id": {
"$oid": "63bc06e6aa310000d6004a6b"
},
"key": "publisher",
"label": "publisher",
"type": "text",
"searchable": 0
},{
"_id": {
"$oid": "63bc06e6aa310000d6004a6c"
},
"key": "published",
"label": "published",
"type": "number",
"searchable": 0
},{
"_id": {
"$oid": "63bc06e6aa310000d6004a6d"
},
"key": "author",
"label": "author",
"type": "text",
"searchable": 0
}]
Now I want to set up an unique index on the key
(text) field. But each time I try to create the index, it produces this error:
Index build failed: 64014369-44e7-4371-976a-25f0aed89614: Collection db.collection ( c9b12814-686b-4603-8e90-bba31f67d930 ) :: caused by :: E11000 duplicate key error collection: db.collection index: key_text dup key: { _fts: "publish", _ftsx: 1.0 }
I have no idea why this appears. As the error indicates, there is no value matching 'publish' in the data. Can anyone please take a look into it and help? Thanks in advance for going through this far and some more if you can point the solution.