我注意到,如果我在某些集合的全文搜索啓用字符串字段中輸入值「四季」,然後MongoDB中發現,當我詢問「季節」這個值。但是如果我輸入更復雜的東西,比如「老鼠」或「標準」,當我分別詢問「鼠標」或「標準」沒有找到這些值。這是否正常,並且MongoDB能夠幹什麼還有什麼不明確的規則?的MongoDB - 全文索引 - 全文檢索 - 制止
[test] 2014-03-30 18:25:09.551 >>> db.TestFullText7.find();
{
"_id" : ObjectId("53389720063ab25d2d55c94c"),
"dt" : ISODate("2014-03-30T22:13:52.717Z"),
"title" : "mice",
"txt" : "mice"
}
{
"_id" : ObjectId("5338994c063ab25d2d55c94d"),
"dt" : ISODate("2014-03-30T22:23:08.259Z"),
"title" : "criteria",
"txt" : "criteria"
}
{
"_id" : ObjectId("533899c5063ab25d2d55c94e"),
"dt" : ISODate("2014-03-30T22:25:09.551Z"),
"title" : "seasons",
"txt" : "seasons"
}
[test] 2014-03-30 18:25:13.295 >>> db.runCommand({"text" : "TestFullText7", "search" : "season"});
{
"queryDebugString" : "season||||||",
"language" : "english",
"results" : [
{
"score" : 2,
"obj" : {
"_id" : ObjectId("533899c5063ab25d2d55c94e"),
"dt" : ISODate("2014-03-30T22:25:09.551Z"),
"title" : "seasons",
"txt" : "seasons"
}
}
],
"stats" : {
"nscanned" : 1,
"nscannedObjects" : 0,
"n" : 1,
"nfound" : 1,
"timeMicros" : 148
},
"ok" : 1
}
[test] 2014-03-30 18:25:22.406 >>> db.runCommand({"text" : "TestFullText7", "search" : "mouse"});
{
"queryDebugString" : "mous||||||",
"language" : "english",
"results" : [ ],
"stats" : {
"nscanned" : 0,
"nscannedObjects" : 0,
"n" : 0,
"nfound" : 0,
"timeMicros" : 110
},
"ok" : 1
}
[test] 2014-03-30 18:25:30.986 >>> db.TestFullText7.getIndexes();
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "test.TestFullText7",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"ns" : "test.TestFullText7",
"name" : "$**_text",
"weights" : {
"$**" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 1
}
]
[test] 2014-03-30 18:25:45.228 >>>
我使用MongoDB的版本2.4.8。 –
彼得,我遇到[問題](http://stackoverflow.com/questions/22766998/stemming-does-not-work-properly-for-mongodb-text-index)使用MongoDB的2.4.8制止。使用你的例子,搜索包含Word文檔「四季」使用文本索引不工作(無論搜索字符串)。只有文檔包含「季節」時,搜索纔會返回。我啓用了文本搜索,創建了一個文本索引(ensureIndex)並使用了全文搜索(runCommand)。我可能會錯過什麼? –