我正在尝试使用text field pymongo索引一个
from pymongo import MongoClient
mongo_client = MongoClient('localhost', 27017)
db = mongo_client["db_name"]这些对象如下所示:
{'_id': ObjectId('5cf7d2d58a662ef15600033f'),
'id': '13055',
'type': 'municipality',
'name': 'Marseille',
'postcode': '13000',
}我试图将字段name索引为string,以便能够对其执行文本搜索,不幸的是,经过多次尝试,我没有成功:
db.collection.create_index([{"$name": "text"}])产生错误:
TypeError: not enough arguments for format string类似地,命令
db.collection.create_index([{"name": "text"}])产生同样的错误:
TypeError: not enough arguments for format string我确信这是一个简单的格式化错误。
发布于 2019-06-06 09:16:19
找到它时,格式必须是:
db.collection.create_index([("name": "text")])https://stackoverflow.com/questions/56474470
复制相似问题