db.getCollection('zhxHotelNotMatch').aggregate( {'$group':{get
'_id': {'字段名': '$字段名'},io
'uniqueIds': {'$addToSet': '$字段名'},db
'count' : {'$sum': 1}co
}},
{'$match': {
'count': {'$gt': 1}
}})
方式二:
db.holMidBaseInfoOne.aggregate( {"$group" : { "_id": "$resPhone", "count": { "$sum": 1 } } }, {"$match": {"_id" :{ "$ne" : null } , "count" : {"$gt": 1} } }, {"$project": {"resPhone" : "$_id", "_id" : 0} })