MongoDB 返回错误 - 未能为 OR 下的 TEXT 生成解决方案 - OR 下的其他非 TEXT 子句也必须编入索引
MongoDB returning error - Failed to produce a solution for TEXT under OR - other non-TEXT clauses under OR have to be indexed as well
我正在尝试 运行 通过 Java 驱动程序对 MongoDB 进行查询,但出现此错误 -
"Query failed with error code 2 and error message 'error processing query: ns=Application.Team limit=10Tree: $or
_id == \"TEA000000006\"
TEXT : query=anonoymous, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL
Sort: { name: 1 }
Proj: { _id: 1, name: 1 }
Collation: { locale: \"en_US\", strength: 1 }
planner returned error: Failed to produce a solution for TEXT under OR -
other non-TEXT clauses under OR have to be indexed as well.' on server
localhost:27017"
我认为索引似乎有问题。
如果我不给出 sort
或 TEXT
,它似乎可以工作。两者一起导致问题
我需要查询在文本搜索中找到的 return 条记录,或者 ID 是否在传递的列表中(在本例中为 TEA0000006)
我的指数是 -
{
"v" : 2,
"name" : "myIndex",
"ns" : "Application.Team",
"weights" : {
"$**" : 1,
"_id" : 1,
"name" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 3
}
{
"v" : NumberInt(2),
"key" : {
"_id" : NumberInt(1)
},
"name" : "_id_",
"ns" : "Application.Team"
}
您需要重新创建没有 _id
和 name
的文本索引。 $**
涵盖所有领域。
如果您只需要这两个字段中的文本索引,请从索引中删除 $**
,因此它应该像 {"_id": "text", "name":"text"}
这实际上是不可能的。参考 - https://jira.mongodb.org/browse/SERVER-13803
我正在尝试 运行 通过 Java 驱动程序对 MongoDB 进行查询,但出现此错误 -
"Query failed with error code 2 and error message 'error processing query: ns=Application.Team limit=10Tree: $or
_id == \"TEA000000006\"
TEXT : query=anonoymous, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL
Sort: { name: 1 }
Proj: { _id: 1, name: 1 }
Collation: { locale: \"en_US\", strength: 1 }
planner returned error: Failed to produce a solution for TEXT under OR -
other non-TEXT clauses under OR have to be indexed as well.' on server
localhost:27017"
我认为索引似乎有问题。
如果我不给出 sort
或 TEXT
,它似乎可以工作。两者一起导致问题
我需要查询在文本搜索中找到的 return 条记录,或者 ID 是否在传递的列表中(在本例中为 TEA0000006)
我的指数是 -
{
"v" : 2,
"name" : "myIndex",
"ns" : "Application.Team",
"weights" : {
"$**" : 1,
"_id" : 1,
"name" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 3
}
{
"v" : NumberInt(2),
"key" : {
"_id" : NumberInt(1)
},
"name" : "_id_",
"ns" : "Application.Team"
}
您需要重新创建没有 _id
和 name
的文本索引。 $**
涵盖所有领域。
如果您只需要这两个字段中的文本索引,请从索引中删除 $**
,因此它应该像 {"_id": "text", "name":"text"}
这实际上是不可能的。参考 - https://jira.mongodb.org/browse/SERVER-13803