{u'field': u'error_starting_process', u'_id':ObjectId('56c2ec225141a3121900188e'), u'severity': u'major', u'description': u'Process failed to start.'}
{u'field': u'process_not_running', u'_id': ObjectId('56c2ec226715991f2000197e'), u'severity': u'minor', u'description': u'Process Asset on host should be running but is not.'}
{u'field': u'process_not_running', u'_id': ObjectId('56c2ec2411debd2b1e0022dd'), u'severity': u'minor', u'description': u'Process Timer Task Execution on host should be running but is not.'}
{u'field': u'error_starting_process', u'_id': ObjectId('56c2ec24df312f091c0021b0'), u'severity': u'major', u'description': u'Process failed to start.'}
如何过滤重复说明?
答案 0 :(得分:1)
您可以使用distinct方法,然后检索与每个描述匹配的第一个文档。 e.g:
for desc in db.collection.distinct("description"):
doc = db.collection.find({"description":desc })[0]