什么版本的mongodb是完整的$ text查询运算符介绍?

时间:2014-08-22 15:52:15

标签: mongodb

愚蠢的问题,对吧?但官方文档的文字索引'说:

http://docs.mongodb.org/manual/core/index-text/
Text Indexes
New in version 2.4.
To perform queries that access the text index, use the $text query operator.

然而,如果您单击帮助以搜索使用$ text运算符创建的索引,则会显示:

http://docs.mongodb.org/manual/reference/operator/query/text/#op._S_text
$text
New in version 2.6.

似乎是2.4,但仍然存在问题。

1 个答案:

答案 0 :(得分:0)

我最近遇到了类似的问题,直到升级到2.6。在2.4中,引入了文本索引作为必须明确启用的实验性功能,请参阅此Mongo 2.4 text article。因此,在启用文本搜索后可以添加文本索引,但实际上需要使用以下方法进行文本搜索:

db.runCommand("text":{search:searchTerm});

目前的语法:

db.collection.find({$text:{$search:searchTerm}});
如果查看MongoDB JIRA bug entitled: Integrate text search into normal query system

似乎已添加到2.5.5中。

我认为这些文档在这方面有点令人困惑,因为它们似乎表明在2.4中只需要启用文本搜索。

相关问题