0

문제가 있습니다.MongoDB 집계 된 셀 삭제

이 같은 문서의 집합이 있습니다

{ 
    id (not _id), 
    type, 
    number 
} 

을 그리고 내가하고 싶은 모든 ID에 대한 이러한 유형의 특정 유형 및 최소 수치는 집계 세포이며,이 컬렉션에서 삭제합니다. 기본적으로 단일 ID는 특정 유형에 대해 몇 가지 다른 번호를 가질 수 있으며 가장 낮은 값을 가진 문서를 삭제하려고합니다.

Java Driver 3 및 mongoshell을 사용하여 집계하려고했지만 구조를 간략히 설명했습니다.

답변

0

List<DBObject> pipeline=new ArrayList<DBObject>(); 
DBObject match = new BasicDBObject("$match", new BasicDBObject("date", sdf.format(new Date())).append("country", country).append("operator", operator).append("server_ip", server_ip)); 
DBObject unwind = new BasicDBObject("$unwind", "$details"); 
DBObject match2 = new BasicDBObject("$match", new BasicDBObject("details.type", "application_health")); 
DBObject sort = new BasicDBObject("$sort", new BasicDBObject("details.datetime", -1)); 
DBObject limit = new BasicDBObject("$limit", 1); 
pipeline.add(match); 
pipeline.add(unwind); 
pipeline.add(match2); 
pipeline.add(sort); 
pipeline.add(limit); 
AggregationOutput outputoutput = collection.aggregate(pipeline); 
같은 것을에서 참조를 취할 수