【发布时间】:2021-10-22 04:36:38
【问题描述】:
我有包含 N 个文档的集合 A。 我的收藏看起来像这样:
{
"_id": "61721b17e52d6033c444059d",
"advertising_venue": "GAP Store, 1440 W Taylor st",
"ad_shelf_name": "11",
"gender": "man",
"age": "25-35",
"distance_to_shelf": "7.035805",
"date": "October 21st 2021 8:59:51 pm",
"user_id": "0.14136775694578052"
},
{
"_id": "61721b18e52d6033c444059e",
"advertising_venue": "GAP Store, 1440 W Taylor st",
"ad_shelf_name": "11",
"gender": "man",
"age": "25-35",
"distance_to_shelf": "8.065434999999999",
"date": "October 21st 2021 8:59:52 pm",
"user_id": "0.14136775694578052"
},
{
"_id": "61721b19e52d6033c444059f",
"advertising_venue": "GAP Store, 1440 W Taylor st",
"ad_shelf_name": "11",
"gender": "man",
"age": "25-35",
"distance_to_shelf": "10.124695",
"date": "October 21st 2021 8:59:53 pm",
"user_id": "0.14136775694578052"
}
我想按 user_id 值比较每个文档,如果相似则删除其中一个文档,如果不相似则保留在集合中。
如果可以在 MongoDB 中做?
【问题讨论】:
-
这里有类似问题和一些想法的帖子:Find duplicate urls in mongodb