我已经基于导入到mongodb中的Yelp的几个json文件创建了3个索引。
> db.review.createIndex({"text":"text"})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
> db.business.createIndex({"categories":"text"})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
> db.business.createIndex({"attributes":"text"})
{
"ok" : 0,
"errmsg" : "Index with pattern: { _fts: \"text\", _ftsx: 1 } already exists with different options",
"code" : 85
基本上,我试图创建3个索引以使mongodb中的count函数更快。
"errmsg" : "Index with pattern: { _fts: \"text\", _ftsx: 1 } already exists with different options"
是什么意思?我应该选择一个不同的东西作为属性,还是应该删除它?
最佳答案
MongoDB (as of v3.4) only allows one text index per collection
在business
集合中,您已经在categories
上建立了文本索引。因此,在attributes
上的第二个文本索引将失败。
关于mongodb - 是什么导致mongodb中的此索引错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43712109/