mongodb - 是什么导致mongodb中的此索引错误?

标签 mongodb indexing compiler-errors

我已经基于导入到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/

相关文章:

mysql - 全文和复合索引以及它们如何影响查询

输入对象没有 const 的 C++ 重载 << 会产生错误,该错误随 const 对象一起消失

node.js - 如何插入嵌套对象数组

mongodb - 取消设置文档::元素,MongoCXX 查找选项投影

sql-server - SQL Server : Create Nonclustered Index without giving a name to it

mysql - 对表中数百万条记录进行分区或索引?

formatting - 如果其格式不符合某些规则,如何使您的代码不可编译?

c# - 有趣的代码片段

mongodb - 为什么大多数 NoSQL DBMS 没有 “pointers” ?

python - Dagster 无法本地连接到 mongodb