db.getCollection('zhxHotelNotMatch').aggregate( {'$group':{
'_id': {'字段名': '$字段名'},
'uniqueIds': {'$addToSet': '$字段名'},
'count' : {'$sum': 1}
}},
{'$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} }
)