在我正在阅读的一本书中,我遇到了这样的陈述:
您不能将多键字段用于任何前缀或后缀索引 字段。
这里的单词是关于一个索引,其中一个字段(中间的一个)被索引为文本,其他字段是普通字段并被索引为非文本。所以我在下面尝试了这个例子,在第四个文档中,我为作者制作了[1,2,3,4]
多作者。不过,我可以使用author作为此索引的postfix索引字段。
(1)这与我认为的书中的陈述相矛盾。任何人都可以解释这是否确实是一个矛盾,如果没有,我在这里缺少什么?
[test] 2014-04-29 18:12:53.329 >>> db.test005.drop();
false
[test] 2014-04-29 18:12:57.724 >>> db.test005.insert({dt:1, txt: "12345", author:"john"});
[test] 2014-04-29 18:15:32.461 >>> db.test005.insert({dt:2, txt: "78780", author:"james"});
[test] 2014-04-29 18:15:44.473 >>> db.test005.insert({dt:3, txt: "90900", author:"nick"});
[test] 2014-04-29 18:15:57.748 >>> db.test005.insert({dt:4, txt: "90444", author:[1,2,3,4]});
[test] 2014-04-29 18:16:12.210 >>> db.test005.find();
{
"_id" : ObjectId("53602484d43f300330d5702e"),
"dt" : 1,
"txt" : "12345",
"author" : "john"
}
{
"_id" : ObjectId("53602490d43f300330d5702f"),
"dt" : 2,
"txt" : "78780",
"author" : "james"
}
{
"_id" : ObjectId("5360249dd43f300330d57030"),
"dt" : 3,
"txt" : "90900",
"author" : "nick"
}
{
"_id" : ObjectId("536024acd43f300330d57031"),
"dt" : 4,
"txt" : "90444",
"author" : [
1,
2,
3,
4
]
}
[test] 2014-04-29 18:16:21.544 >>> db.test005.ensureIndex({"dt" : 1, "txt" : "text", "author" : 1});
{
"err" : "text search not enabled",
"code" : 16633,
"n" : 0,
"connectionId" : 1,
"ok" : 1
}
[test] 2014-04-29 18:17:28.16 >>> db.adminCommand({"setParameter" : 1, "textSearchEnabled" : true}) ;
{ "was" : false, "ok" : 1 }
[test] 2014-04-29 18:22:15.316 >>> db.test005.ensureIndex({"dt" : 1, "txt" : "text", "author" : 1});
[test] 2014-04-29 18:22:19.63 >>>
(2)另一个相关奇怪的事情就是这个错误 我在运行解释时稍后会得到它。
[test] 2014-04-29 18:38:24.13 >>> db.test005.find({"dt": 10, "txt": "2020", "author": "rich"}).explain();
Tue Apr 29 18:40:20.872 error: { "$err" : "assertion src\\mongo\\db\\fts\\fts_index.cpp:55" } at src/mongo/shell/query.js:128
[test] 2014-04-29 18:40:20.872 >>>
为什么我收到此错误?
我使用的是MongoDB版本2.4.8。
修改
以下是日志文件中与项目(2)相关的错误。
Sun May 04 07:49:25.193 [initandlisten] MongoDB starting : pid=2972 port=27017 dbpath=C:\Programs\MongoDB\data 64-bit host=YBLAP4R25CN1
Sun May 04 07:49:25.195 [initandlisten] db version v2.4.8
Sun May 04 07:49:25.195 [initandlisten] git version: a350fc38922fbda2cec8d5dd842237b904eafc14
Sun May 04 07:49:25.195 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
Sun May 04 07:49:25.195 [initandlisten] allocator: system
Sun May 04 07:49:25.195 [initandlisten] options: { config: "C:\Programs\MongoDB\run\mongo-app.conf", dbpath: "C:\Programs\MongoDB\data", logappend: "true", logpath: "C:\Programs\MongoDB\log\mongo-app.log" }
Sun May 04 07:49:25.282 [initandlisten] journal dir=C:\Programs\MongoDB\data\journal
Sun May 04 07:49:25.283 [initandlisten] recover : no journal files present, no recovery needed
Sun May 04 07:49:25.786 [websvr] admin web console waiting for connections on port 28017
Sun May 04 07:49:25.786 [initandlisten] waiting for connections on port 27017
Sun May 04 07:49:31.240 [initandlisten] connection accepted from 127.0.0.1:54205 #1 (1 connection now open)
Sun May 04 07:49:40.823 [conn1] test.test005 Assertion failure 0 src\mongo\db\fts\fts_index.cpp 55
Sun May 04 07:49:49.688 [conn1] mongod.exe ...\src\mongo\util\stacktrace.cpp(167) mongo::printStackTrace+0x3e
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\util\assert_util.cpp(114) mongo::verifyFailed+0xdc
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\fts\fts_index.cpp(55) mongo::fts::FTSIndex::newCursor+0x3e
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\queryoptimizer.cpp(274) mongo::QueryPlan::newCursor+0x75
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\queryoptimizercursorimpl.cpp(492) mongo::CursorGenerator::singlePlanCursor+0xc8
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\queryoptimizercursorimpl.cpp(525) mongo::CursorGenerator::generate+0xad
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\queryoptimizercursorimpl.cpp(400) mongo::NamespaceDetailsTransient::getCursor+0x6c
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\ops\query.cpp(698) mongo::queryWithQueryOptimizer+0x1ff
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\ops\query.cpp(1047) mongo::runQuery+0x1380
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\instance.cpp(262) mongo::receivedQuery+0x35d
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\instance.cpp(401) mongo::assembleResponse+0x2f0
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\db\db.cpp(194) mongo::MyMessageHandler::process+0xfa
Sun May 04 07:49:49.689 [conn1] mongod.exe ...\src\mongo\util\net\message_server_port.cpp(207) mongo::PortMessageServer::handleIncomingMsg+0x578
Sun May 04 07:49:49.690 [conn1] mongod.exe ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(180) boost::`anonymous namespace'::thread_start_function+0x21
Sun May 04 07:49:49.690 [conn1] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314) _callthreadstartex+0x17
Sun May 04 07:49:49.690 [conn1] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292) _threadstartex+0x7f
Sun May 04 07:49:49.690 [conn1] kernel32.dll BaseThreadInitThunk+0xd
Sun May 04 07:49:49.730 [conn1] assertion 0 assertion src\mongo\db\fts\fts_index.cpp:55 ns:test.test005 query:{ query: { dt: 10.0, txt: "2020", author: "rich" }, $explain: true }
Sun May 04 07:49:49.730 [conn1] query test.test005 query: { query: { dt: 10.0, txt: "2020", author: "rich" }, $explain: true } ntoreturn:0 keyUpdates:0 exception: assertion src\mongo\db\fts\fts_index.cpp:55 locks(micros) W:16500 r:8960197 reslen:79 8960ms