本文整理汇总了Java中org.springframework.data.mongodb.core.aggregation.Aggregation.match方法的典型用法代码示例。如果您正苦于以下问题:Java Aggregation.match方法的具体用法?Java Aggregation.match怎么用?Java Aggregation.match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.mongodb.core.aggregation.Aggregation
的用法示例。
在下文中一共展示了Aggregation.match方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWeaverInfosInCode
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
/** 회원의 코드 정보를 aggregation을 활용하여 가져옴
* @param weaver
* @return 회원의 코드 활동 내역
*/
public DBObject getWeaverInfosInCode(Weaver weaver){
Criteria criteria = Criteria.where("writer.$id").is(weaver.getId());
AggregationOperation match = Aggregation.match(criteria);
AggregationOperation group = Aggregation. group("writer").count().as("codeCount").sum("downCount").as("downCount");
Aggregation agg = newAggregation(match, group);
return mongoTemplate.aggregate(agg, "code", DBObject.class).getUniqueMappedResult();
}
示例2: findCommentsCountGreaterThanBoardIdAndBoard
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
/**
* boardItem의 boardId 기준 이상의 댓글 수를 가져온다
*
* @param boardId 기준이 되는 boardItem의 boardId
*/
@Override
public List<CommonCount> findCommentsCountGreaterThanBoardIdAndBoard(ObjectId boardId, Constants.BOARD_TYPE board) {
AggregationOperation match1 = Aggregation.match(Criteria.where("article._id").gt(boardId).and("article.board").is(board.name()));
AggregationOperation group = Aggregation.group("article").count().as("count");
AggregationOperation sort = Aggregation.sort(Sort.Direction.DESC, "count");
//AggregationOperation limit = Aggregation.limit(Constants.BOARD_TOP_LIMIT);
Aggregation aggregation = Aggregation.newAggregation(match1, group, sort/*, limit*/);
AggregationResults<CommonCount> results = mongoTemplate.aggregate(aggregation, Constants.COLLECTION_ARTICLE_COMMENT, CommonCount.class);
return results.getMappedResults();
}
示例3: findById
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
@Test
public void findById() {
ArrayList<ObjectId> arrTemp = new ArrayList<ObjectId>();
arrTemp.add(new ObjectId("54c4df893d96600d7f55a048"));
arrTemp.add(new ObjectId("54c4e4833d96deb0f8592907"));
AggregationOperation match = Aggregation.match(Criteria.where("_id").in(arrTemp));
//AggregationOperation group = Aggregation.group("article").count().as("count");
AggregationOperation sort = Aggregation.sort(Direction.ASC, "_id");
//AggregationOperation limit = Aggregation.limit(Constants.BOARD_LINE_NUMBER);
Aggregation aggregation = Aggregation.newAggregation(match, /*group, */ sort /*, limit*/);
AggregationResults<Gallery> results = mongoTemplate.aggregate(aggregation, "gallery", Gallery.class);
System.out.println("findOneById=" + results.getMappedResults());
}
示例4: getWeaverInfosInPost
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
/** 회원의 게시글 정보를 aggregation을 활용하여 가져옴
* @param weaver
* @return 회원의 커뮤니티 활동 내역
*/
public DBObject getWeaverInfosInPost(Weaver weaver){
Criteria criteria = Criteria.where("writer.$id").is(weaver.getId());
AggregationOperation match = Aggregation.match(criteria);
AggregationOperation group = Aggregation. group("writer").count().as("postCount").sum("push").as("push").sum("rePostCount").as("rePostCount");
Aggregation agg = newAggregation(match, group);
return mongoTemplate.aggregate(agg, "post", DBObject.class).getUniqueMappedResult();
}
示例5: getWeaverInfosInRePost
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
/** 회원의 답변 정보를 aggregation을 활용하여 가져옴
* @param weaver
* @return 회원의 답변 활동 내역
*/
public DBObject getWeaverInfosInRePost(Weaver weaver){
Criteria criteria = Criteria.where("writer.$id").is(weaver.getId());
AggregationOperation match = Aggregation.match(criteria);
AggregationOperation group = Aggregation. group("writer").count().as("myRePostCount").sum("push").as("rePostPush").push("replys").as("replys");
Aggregation agg = newAggregation(match, group);
return mongoTemplate.aggregate(agg, "rePost", DBObject.class).getUniqueMappedResult();
}
示例6: getWeaverInfosInRepository
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
/** 회원의 저장소 정보를 aggregation을 활용하여 가져옴
* @param weaver
* @return 회원의 저장소 활동 내역
*/
public DBObject getWeaverInfosInRepository(Weaver weaver){
Criteria criteria = Criteria.where("creator.$id").is(weaver.getId());
AggregationOperation match = Aggregation.match(criteria);
AggregationOperation group = Aggregation.group("creator").sum("push").as("repositoryPush");
Aggregation agg = newAggregation(match, group);
return mongoTemplate.aggregate(agg, "repository", DBObject.class).getUniqueMappedResult();
}
示例7: getWeaverInfosInLecture
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
/** 회원의 강의 정보를 aggregation을 활용하여 가져옴
* @param weaver
* @return 회원의 강의 활동 내역
*/
public DBObject getWeaverInfosInLecture(Weaver weaver){
Criteria criteria = Criteria.where("creator.$id").is(weaver.getId());
AggregationOperation match = Aggregation.match(criteria);
AggregationOperation group = Aggregation. group("creator").push("joinWeavers").as("joinWeavers").push("repos").as("repos");
Aggregation agg = newAggregation(match, group);
return mongoTemplate.aggregate(agg, "lecture", DBObject.class).getUniqueMappedResult();
}
示例8: getSupportFCCount
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
public List<SupporterCount> getSupportFCCount(String language) {
AggregationOperation match = Aggregation.match(Criteria.where("supportFC").exists(true));
AggregationOperation group = Aggregation.group("supportFC").count().as("count");
AggregationOperation project = Aggregation.project("count").and("_id").as("supportFC");
AggregationOperation sort = Aggregation.sort(Direction.DESC, "count");
Aggregation aggregation = Aggregation.newAggregation(match, group, project, sort);
AggregationResults<SupporterCount> results = mongoTemplate.aggregate(aggregation, "user", SupporterCount.class);
List<SupporterCount> users = results.getMappedResults();
for (SupporterCount supporterCount : users) {
supporterCount.getSupportFC().getNames().removeIf(fcName -> !fcName.getLanguage().equals(language));
}
return users;
}
示例9: getJakduComments
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
public List<JakduComment> getJakduComments(String jakduScheduleId, ObjectId commentId) {
AggregationOperation match1 = Aggregation.match(Criteria.where("jakduScheduleId").is(jakduScheduleId));
AggregationOperation match2 = Aggregation.match(Criteria.where("_id").gt(commentId));
AggregationOperation sort = Aggregation.sort(Direction.ASC, "_id");
AggregationOperation limit = Aggregation.limit(Constants.COMMENT_MAX_LIMIT);
Aggregation aggregation;
if (Objects.nonNull(commentId)) {
aggregation = Aggregation.newAggregation(match1, match2, sort, limit);
} else {
aggregation = Aggregation.newAggregation(match1, sort, limit);
}
AggregationResults<JakduComment> results = mongoTemplate.aggregate(aggregation, "jakduComment", JakduComment.class);
List<JakduComment> comments = results.getMappedResults();
return comments;
}
示例10: findCommentsGreaterThanId
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
/**
* 기준 ArticleComment ID 이상의 ArticleComment 목록을 가져온다.
*/
@Override
public List<ArticleComment> findCommentsGreaterThanId(ObjectId objectId, Integer limit) {
AggregationOperation match1 = Aggregation.match(Criteria.where("_id").gt(objectId));
AggregationOperation sort = Aggregation.sort(Sort.Direction.ASC, "_id");
AggregationOperation limit1 = Aggregation.limit(limit);
Aggregation aggregation;
if (! ObjectUtils.isEmpty(objectId)) {
aggregation = Aggregation.newAggregation(match1, sort, limit1);
} else {
aggregation = Aggregation.newAggregation(sort, limit1);
}
AggregationResults<ArticleComment> results = mongoTemplate.aggregate(aggregation, Constants.COLLECTION_ARTICLE_COMMENT, ArticleComment.class);
return results.getMappedResults();
}
示例11: findCommentsCountByIds
import org.springframework.data.mongodb.core.aggregation.Aggregation; //导入方法依赖的package包/类
/**
* 게시물 ID 에 해당하는 댓글 수를 가져온다.
*/
@Override
public List<CommonCount> findCommentsCountByIds(List<ObjectId> ids) {
AggregationOperation match = Aggregation.match(Criteria.where("article._id").in(ids));
AggregationOperation group = Aggregation.group("article").count().as("count");
//AggregationOperation sort = Aggregation.sort(Direction.ASC, "_id");
//AggregationOperation limit = Aggregation.limit(Constants.BOARD_LINE_NUMBER);
Aggregation aggregation = Aggregation.newAggregation(match, group/*, sort, limit*/);
AggregationResults<CommonCount> results = mongoTemplate.aggregate(aggregation, Constants.COLLECTION_ARTICLE_COMMENT, CommonCount.class);
return results.getMappedResults();
}