我的收藏集posts
包含看起来像这样的帖子
{
"_id": "5ae37fd270f3e72399988198",
"moderator": {
"flagged": false,
"reviewed": true,
"pending": false,
"time": "2018-04-27 20:34:38.099000",
"account": "samhamou"
},
"author": "cryptohazard",
"permlink": "security-enhancements-for-steem-messenger",
"title": "Security enhancements for Steem Messenger",
"repository": {
"owner": {
"login": "kingswisdom"
},
"fork": false,
"html_url": "https:\/\/github.com\/kingswisdom\/SteemMessenger",
"full_name": "kingswisdom\/SteemMessenger",
"name": "SteemMessenger",
"id": 127418766
}
}
我正在尝试使用以下代码在我的一个Python文件中创建集合的索引
posts = DB.posts
posts.drop_indexes()
posts.create_index([
("author", "text"),
("moderator.account", "text"),
("repository.full_name", "text")
])
但是这给了我以下错误:
pymongo.errors.OperationFailure: language override unsupported: C++
如何防止这种情况发生?我可以使用this question的答案中的代码创建索引:
> db.posts.createIndex({
"moderator.account": "text",
author: "text",
"repository.full_name": "text"
}, {
"language_override": "en"
});
但是我希望能够在我的Python脚本中执行此操作,而不必从MongoDB shell中执行此操作。我尝试在我的Python脚本中找到一种添加"language_override": "en"
选项的方法,但在检查documentation for create_index时似乎无法做到这一点。