0
我想總結出現在所有文檔中的2個字段(favorite_count和retweet_count。)然後添加結果作爲一個新的領域(或更新):
filter = {'user.screen_name':author}
db.dwh_twt_tweets.update_many(filter= filter, update= {"$project":{
'favorite_count':'$favorite_count',
'retweet_count':'$retweet_count',
'interactions':{"$add":
['$favorite_count','$retweet_count']}
}
}
)
我得到:
raise WriteError(error.get("errmsg"), error.get("code"), error)
pymongo.errors.WriteError: Unknown modifier: $project
作爲替代我試圖替換爲$項目$設置,但在這種情況下,錯誤,我得到是:
pymongo.errors.WriteError: The dollar ($) prefixed field '$add'
in 'interactions.$add' is not valid for storage.
剛刪除(filter =,update =),同樣的錯誤 –