MongoDB-全文索引-全文搜索-词干分析

MongoDB-全文索引-全文搜索-词干分析,mongodb,indexing,full-text-search,Mongodb,Indexing,Full Text Search,我注意到,如果我在某个集合的启用全文搜索的字符串字段中输入值'seasons',那么MongoDB会在我查询'seasons'时找到这个值。但是,如果我输入了更复杂的内容,例如“鼠标”或“条件”,那么当我分别查询“鼠标”或“条件”时,它不会找到这些值。这正常吗?MongoDB能够阻止什么和不能阻止什么有明确的规则吗 [test] 2014-03-30 18:25:09.551 >>> db.TestFullText7.find(); { "_id" : Obje

我注意到,如果我在某个集合的启用全文搜索的字符串字段中输入值'seasons',那么MongoDB会在我查询'seasons'时找到这个值。但是,如果我输入了更复杂的内容,例如“鼠标”或“条件”,那么当我分别查询“鼠标”或“条件”时,它不会找到这些值。这正常吗?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使用雪球词干库。不幸的是,这似乎是该库的限制之一

您可以看到英文词干分析器的页面 . 比较词汇表+词干等效页面,您可以看到“鼠标”变为“鼠标”,而“鼠标”仍然是“鼠标”


您可以在他们的代码库中看到MongoDB对Snowball的使用,

我正在使用MongoDB版本2.4.8。Peter,我正在使用MongoDB 2.4.8进行词干处理。使用您的示例,使用文本索引搜索包含单词“seasons”的文档不起作用(无论搜索字符串如何)。只有当文档包含“季节”时,搜索才会返回它。我启用了文本搜索,创建了文本索引(ensureIndex)并使用全文搜索(runCommand)。我会错过什么?谢谢你。你能告诉我一些权威的参考资料吗,它们表明MongoDB正在使用Snowball词干库?没问题。在我的答案中添加了一对链接。