【发布时间】:2016-03-06 02:12:01
【问题描述】:
我正在尝试使用聚合框架进行简单的文本搜索。我正在使用 Mongo 3.0.7
数据库有一个名为“文本”的字段。我正在尝试使用 python 从 mongo 检索数据。我正在使用下面的代码。如果我错了,请纠正我。
db.tweets.create_index({"text":"text"})
cursor=db.tweets.aggregate(([{"match": {"text": {"search": "cake"}}}]))
for document in cursor:
print(document)
我收到错误:规划器返回错误:$text 查询需要一个文本索引。
谢谢!
【问题讨论】:
标签: python mongodb python-3.x mongodb-query pymongo