本文整理了Java中com.mongodb.client.model.Aggregates.unwind()
方法的一些代码示例,展示了Aggregates.unwind()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Aggregates.unwind()
方法的具体详情如下:
包路径:com.mongodb.client.model.Aggregates
类名称:Aggregates
方法名:unwind
[英]Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a '$' sign.
[中]为指定的字段名创建$unwind pipeline阶段,该字段名必须以“$”符号作为前缀。
代码示例来源:origin: epam/DLab
static Bson unwindField(String fieldName) {
return unwind(FIELD_PROJECTION_DELIMITER + fieldName);
}
代码示例来源:origin: T-baby/MongoDB-Plugin
public MongoAggregation unwind(String field) {
pipeline.add(Aggregates.unwind(field, unwindOptions));
return this;
}
代码示例来源:origin: com.cybermkd/MongodbPlugin
public MongoAggregation unwind(String field) {
pipeline.add(Aggregates.unwind(field, unwindOptions));
return this;
}
代码示例来源:origin: T-baby/MongoDB-Plugin
public MongoAggregation unwind(String field, UnwindOptions unwindOptions) {
pipeline.add(Aggregates.unwind(field, unwindOptions));
return this;
}
代码示例来源:origin: com.cybermkd/MongodbPlugin
public MongoAggregation unwind(String field, UnwindOptions unwindOptions) {
pipeline.add(Aggregates.unwind(field, unwindOptions));
return this;
}
代码示例来源:origin: creactiviti/piper
@Override
public List<TaskExecution> findByParentId(String aParentId) {
return collection
.aggregate(ImmutableList.of(
unwind('$' + DSL.EXECUTION),
match(eq(format("{0}.parentId", DSL.EXECUTION), aParentId)),
unwind('$' + DSL.EXECUTION)
))
.into(new ArrayList<>());
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence
private static Bson createSecondUnwindStage() {
return unwind(FIELD_GRANTS_VARIABLE, new UnwindOptions().preserveNullAndEmptyArrays(true));
}
代码示例来源:origin: eclipse/ditto
private static Bson createSecondUnwindStage() {
return unwind(FIELD_GRANTS_VARIABLE, new UnwindOptions().preserveNullAndEmptyArrays(true));
}
代码示例来源:origin: creactiviti/piper
@Override
public TaskExecution findOne(String aId) {
return collection
.aggregate(ImmutableList.of(
unwind('$' + DSL.EXECUTION),
match(eq(format("{0}._id", DSL.EXECUTION), aId)),
replaceRoot('$' + DSL.EXECUTION)
))
.first();
}
代码示例来源:origin: creactiviti/piper
@Override
public List<TaskExecution> getExecution(String aJobId) {
return collection
.aggregate(ImmutableList.of(
match(eq("_id", aJobId)),
unwind('$' + DSL.EXECUTION),
replaceRoot('$' + DSL.EXECUTION)
))
.into(new ArrayList<>());
}
代码示例来源:origin: opencb/opencga
@Override
public Long variableSetExists(long variableSetId) {
List<Bson> aggregation = new ArrayList<>();
aggregation.add(Aggregates.match(Filters.elemMatch(QueryParams.VARIABLE_SET.key(),
Filters.eq(VariableSetParams.UID.key(), variableSetId))));
aggregation.add(Aggregates.project(Projections.include(QueryParams.VARIABLE_SET.key())));
aggregation.add(Aggregates.unwind("$" + QueryParams.VARIABLE_SET.key()));
aggregation.add(Aggregates.match(Filters.eq(QueryParams.VARIABLE_SET_UID.key(), variableSetId)));
QueryResult<VariableSet> queryResult = studyCollection.aggregate(aggregation, variableSetConverter, new QueryOptions());
return (long) queryResult.getResult().size();
}
代码示例来源:origin: opencb/opencga
@Override
public QueryResult<Group> getGroup(long studyId, @Nullable String groupId, List<String> userIds) throws CatalogDBException {
long startTime = startQuery();
checkId(studyId);
if (userIds == null) {
userIds = Collections.emptyList();
}
List<Bson> aggregation = new ArrayList<>();
aggregation.add(Aggregates.match(Filters.eq(PRIVATE_UID, studyId)));
aggregation.add(Aggregates.project(Projections.include(QueryParams.GROUPS.key())));
aggregation.add(Aggregates.unwind("$" + QueryParams.GROUPS.key()));
if (userIds.size() > 0) {
aggregation.add(Aggregates.match(Filters.in(QueryParams.GROUP_USER_IDS.key(), userIds)));
}
if (groupId != null && groupId.length() > 0) {
aggregation.add(Aggregates.match(Filters.eq(QueryParams.GROUP_NAME.key(), groupId)));
}
QueryResult<Document> queryResult = studyCollection.aggregate(aggregation, null);
List<Study> studies = MongoDBUtils.parseStudies(queryResult);
List<Group> groups = new ArrayList<>();
studies.stream().filter(study -> study.getGroups() != null).forEach(study -> groups.addAll(study.getGroups()));
return endQuery("getGroup", startTime, groups);
}
代码示例来源:origin: opencb/opencga
aggregates.add(Aggregates.unwind("$projects"));
aggregates.add(Aggregates.match(bsonQuery));
代码示例来源:origin: opencb/opencga
aggregation.add(Aggregates.match(Filters.eq(PRIVATE_UID, studyId)));
aggregation.add(Aggregates.project(Projections.include("variableSets")));
aggregation.add(Aggregates.unwind("$variableSets"));
if (mongoQueryList.size() > 0) {
List<Bson> bsonList = new ArrayList<>(mongoQueryList.size());
代码示例来源:origin: org.opencb.cellbase/cellbase-lib
@Override
public QueryResult nativeGet(Query query, QueryOptions options) {
Bson bson = parseQuery(query);
Bson match = Aggregates.match(bson);
Bson project = Aggregates.project(Projections.include("transcripts.xrefs"));
Bson unwind = Aggregates.unwind("$transcripts");
Bson unwind2 = Aggregates.unwind("$transcripts.xrefs");
// This project the three fields of Xref to the top of the object
Document document = new Document("id", "$transcripts.xrefs.id");
document.put("dbName", "$transcripts.xrefs.dbName");
document.put("dbDisplayName", "$transcripts.xrefs.dbDisplayName");
Bson project1 = Aggregates.project(document);
if (query.containsKey(QueryParams.DBNAME.key())) {
Bson bson2 = parseQuery(new Query(QueryParams.DBNAME.key(), query.get(QueryParams.DBNAME.key())));
Bson match2 = Aggregates.match(bson2);
return mongoDBCollection.aggregate(Arrays.asList(match, project, unwind, unwind2, match2, project1), options);
}
return mongoDBCollection.aggregate(Arrays.asList(match, project, unwind, unwind2, project1), options);
}
代码示例来源:origin: opencb/cellbase
@Override
public QueryResult nativeGet(Query query, QueryOptions options) {
Bson bson = parseQuery(query);
Bson match = Aggregates.match(bson);
Bson project = Aggregates.project(Projections.include("transcripts.xrefs"));
Bson unwind = Aggregates.unwind("$transcripts");
Bson unwind2 = Aggregates.unwind("$transcripts.xrefs");
// This project the three fields of Xref to the top of the object
Document document = new Document("id", "$transcripts.xrefs.id");
document.put("dbName", "$transcripts.xrefs.dbName");
document.put("dbDisplayName", "$transcripts.xrefs.dbDisplayName");
Bson project1 = Aggregates.project(document);
if (query.containsKey(QueryParams.DBNAME.key())) {
Bson bson2 = parseQuery(new Query(QueryParams.DBNAME.key(), query.get(QueryParams.DBNAME.key())));
Bson match2 = Aggregates.match(bson2);
return mongoDBCollection.aggregate(Arrays.asList(match, project, unwind, unwind2, match2, project1), options);
}
return mongoDBCollection.aggregate(Arrays.asList(match, project, unwind, unwind2, project1), options);
}
代码示例来源:origin: opencb/cellbase
@Override
public QueryResult<Long> count(Query query) {
Bson document = parseQuery(query);
Bson match = Aggregates.match(document);
List<String> includeFields = new ArrayList<>();
for (String s : query.keySet()) {
if (StringUtils.isNotEmpty(query.getString(s))) {
includeFields.add(s);
}
}
Bson include;
if (includeFields.size() > 0) {
include = Aggregates.project(Projections.include(includeFields));
} else {
include = Aggregates.project(Projections.include("transcripts.id"));
}
Bson unwind = Aggregates.unwind("$transcripts");
Bson match2 = Aggregates.match(document);
Bson project = Aggregates.project(new Document("transcripts", "$transcripts.id"));
Bson group = Aggregates.group("transcripts", Accumulators.sum("count", 1));
QueryResult<Document> queryResult =
mongoDBCollection.aggregate(Arrays.asList(match, include, unwind, match2, project, group), null);
Number number = (Number) queryResult.first().get("count");
Long count = number.longValue();
return new QueryResult<>(null, queryResult.getDbTime(), queryResult.getNumResults(),
queryResult.getNumTotalResults(), queryResult.getWarningMsg(), queryResult.getErrorMsg(),
Collections.singletonList(count));
}
代码示例来源:origin: org.opencb.cellbase/cellbase-lib
@Override
public QueryResult<Long> count(Query query) {
Bson document = parseQuery(query);
Bson match = Aggregates.match(document);
List<String> includeFields = new ArrayList<>();
for (String s : query.keySet()) {
if (StringUtils.isNotEmpty(query.getString(s))) {
includeFields.add(s);
}
}
Bson include;
if (includeFields.size() > 0) {
include = Aggregates.project(Projections.include(includeFields));
} else {
include = Aggregates.project(Projections.include("transcripts.id"));
}
Bson unwind = Aggregates.unwind("$transcripts");
Bson match2 = Aggregates.match(document);
Bson project = Aggregates.project(new Document("transcripts", "$transcripts.id"));
Bson group = Aggregates.group("transcripts", Accumulators.sum("count", 1));
QueryResult<Document> queryResult =
mongoDBCollection.aggregate(Arrays.asList(match, include, unwind, match2, project, group), null);
Number number = (Number) queryResult.first().get("count");
Long count = number.longValue();
return new QueryResult<>(null, queryResult.getDbTime(), queryResult.getNumResults(),
queryResult.getNumTotalResults(), queryResult.getWarningMsg(), queryResult.getErrorMsg(),
Collections.singletonList(count));
}
代码示例来源:origin: opencb/cellbase
Bson unwind = Aggregates.unwind("$transcripts");
Bson unwind2 = Aggregates.unwind("$transcripts.tfbs");
代码示例来源:origin: org.opencb.cellbase/cellbase-lib
Bson unwind = Aggregates.unwind("$transcripts");
Bson unwind2 = Aggregates.unwind("$transcripts.tfbs");
内容来源于网络,如有侵权,请联系作者删除!