本文整理了Java中com.mongodb.client.model.Aggregates.match()
方法的一些代码示例,展示了Aggregates.match()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Aggregates.match()
方法的具体详情如下:
包路径:com.mongodb.client.model.Aggregates
类名称:Aggregates
方法名:match
[英]Creates a $match pipeline stage for the specified filter
[中]为指定的筛选器创建$match pipeline阶段
代码示例来源:origin: org.apache.rya/mongodb.rya
/**
* Add a step to the end of the current pipeline which prunes the results
* according to the timestamps of their sources. At least one triple that
* was used to construct the result must have a timestamp at least as
* recent as the parameter. Use in iterative applications to avoid deriving
* solutions that would have been generated in an earlier iteration.
* @param t Minimum required timestamp. Reject a solution to the query if
* all of the triples involved in producing that solution have an earlier
* timestamp than this.
*/
public void requireSourceTimestamp(long t) {
pipeline.add(Aggregates.match(new Document(TIMESTAMP,
new Document("$gte", t))));
}
代码示例来源:origin: apache/incubator-rya
/**
* Add a step to the end of the current pipeline which prunes the results
* according to the timestamps of their sources. At least one triple that
* was used to construct the result must have a timestamp at least as
* recent as the parameter. Use in iterative applications to avoid deriving
* solutions that would have been generated in an earlier iteration.
* @param t Minimum required timestamp. Reject a solution to the query if
* all of the triples involved in producing that solution have an earlier
* timestamp than this.
*/
public void requireSourceTimestamp(final long t) {
pipeline.add(Aggregates.match(new Document(TIMESTAMP,
new Document("$gte", t))));
}
代码示例来源:origin: org.apache.rya/mongodb.rya
/**
* Add a step to the end of the current pipeline which prunes the results
* according to the recorded derivation level of their sources. At least one
* triple that was used to construct the result must have a derivation level
* at least as high as the parameter, indicating that it was derived via
* that many steps from the original data. (A value of zero is equivalent to
* input data that was not derived at all.) Use in conjunction with
* getTriplePipeline (which sets source level for generated triples) to
* avoid repeatedly deriving the same results.
* @param requiredLevel Required derivation depth. Reject a solution to the
* query if all of the triples involved in producing that solution have a
* lower derivation depth than this. If zero, does nothing.
*/
public void requireSourceDerivationDepth(int requiredLevel) {
if (requiredLevel > 0) {
pipeline.add(Aggregates.match(new Document(LEVEL,
new Document("$gte", requiredLevel))));
}
}
代码示例来源: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: apache/incubator-rya
/**
* Create a pipeline query node based on a StatementPattern.
* @param collection The collection of triples to query.
* @param baseSP The leaf node in the query tree.
*/
public AggregationPipelineQueryNode(final MongoCollection<Document> collection, final StatementPattern baseSP) {
this.collection = Preconditions.checkNotNull(collection);
Preconditions.checkNotNull(baseSP);
this.varToOriginalName = HashBiMap.create();
final StatementVarMapping mapping = new StatementVarMapping(baseSP, varToOriginalName);
this.assuredBindingNames = new HashSet<>(mapping.varNames());
this.bindingNames = new HashSet<>(mapping.varNames());
this.pipeline = new LinkedList<>();
this.pipeline.add(Aggregates.match(getMatchExpression(baseSP)));
this.pipeline.add(Aggregates.project(mapping.getProjectExpression()));
}
代码示例来源:origin: org.apache.rya/mongodb.rya
/**
* Create a pipeline query node based on a StatementPattern.
* @param collection The collection of triples to query.
* @param baseSP The leaf node in the query tree.
*/
public AggregationPipelineQueryNode(MongoCollection<Document> collection, StatementPattern baseSP) {
this.collection = Preconditions.checkNotNull(collection);
Preconditions.checkNotNull(baseSP);
this.varToOriginalName = HashBiMap.create();
StatementVarMapping mapping = new StatementVarMapping(baseSP, varToOriginalName);
this.assuredBindingNames = new HashSet<>(mapping.varNames());
this.bindingNames = new HashSet<>(mapping.varNames());
this.pipeline = new LinkedList<>();
this.pipeline.add(Aggregates.match(getMatchExpression(baseSP)));
this.pipeline.add(Aggregates.project(mapping.getProjectExpression()));
}
代码示例来源: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: creactiviti/piper
@Override
public List<Context> getStack(String aStackId) {
return collection
.withDocumentClass(Context.class)
.aggregate(ImmutableList.of(
match(eq("stackId", aStackId)),
sort(descending("createTime")),
replaceRoot("$context")
))
.into(new ArrayList<>());
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence
private static Bson createInitialMatchStageWithDeleted(final Criteria filterCriteria,
final Criteria aclCriteria, final Criteria globalPolicyGrantsCriteria) {
final Bson authorization =
or(CreateBsonVisitor.apply(globalPolicyGrantsCriteria), CreateBsonVisitor.apply(aclCriteria));
return match(and(authorization, CreateBsonVisitor.apply(filterCriteria)));
}
代码示例来源:origin: eclipse/ditto
private static Bson createInitialMatchStageWithDeleted(final Criteria filterCriteria,
final Criteria aclCriteria, final Criteria globalPolicyGrantsCriteria) {
final Bson authorization =
or(CreateBsonVisitor.apply(globalPolicyGrantsCriteria), CreateBsonVisitor.apply(aclCriteria));
return match(and(authorization, CreateBsonVisitor.apply(filterCriteria)));
}
代码示例来源:origin: com.cybermkd/MongodbPlugin
public MongoAggregation(MongoQuery query) {
/*复用MongoQuery*/
this.query = query;
if (query.getQuery() != null && !query.getQuery().isEmpty()) {
pipeline.add(Aggregates.match(Filters.and(query.getQuery())));
}
if (query.getSort() != null) {
pipeline.add(Aggregates.sort(query.getSort()));
}
if (query.getSkip() > 0) {
pipeline.add(Aggregates.skip(query.getSkip()));
}
if (query.getLimit() > 0) {
pipeline.add(Aggregates.limit(query.getLimit()));
}
}
代码示例来源:origin: T-baby/MongoDB-Plugin
public MongoAggregation(MongoQuery query) {
/*复用MongoQuery*/
this.query = query;
if (query.getQuery() != null && !query.getQuery().isEmpty()) {
pipeline.add(Aggregates.match(Filters.and(query.getQuery())));
}
if (query.getSort() != null) {
pipeline.add(Aggregates.sort(query.getSort()));
}
if (query.getSkip() > 0) {
pipeline.add(Aggregates.skip(query.getSkip()));
}
if (query.getLimit() > 0) {
pipeline.add(Aggregates.limit(query.getLimit()));
}
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence
private static Bson createInitialMatchStageWithNonDeleted(final Criteria filterCriteria,
final Criteria aclCriteria, final Criteria globalPolicyGrantsCriteria) {
final Bson authorization =
or(CreateBsonVisitor.apply(globalPolicyGrantsCriteria), CreateBsonVisitor.apply(aclCriteria));
return match(and(authorization, filterNotDeleted(), CreateBsonVisitor.apply(filterCriteria)));
}
代码示例来源:origin: eclipse/ditto
private static Bson createInitialMatchStageWithNonDeleted(final Criteria filterCriteria,
final Criteria aclCriteria, final Criteria globalPolicyGrantsCriteria) {
final Bson authorization =
or(CreateBsonVisitor.apply(globalPolicyGrantsCriteria), CreateBsonVisitor.apply(aclCriteria));
return match(and(authorization, filterNotDeleted(), CreateBsonVisitor.apply(filterCriteria)));
}
代码示例来源: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: creactiviti/piper
@Override
public Context peek(String aStackId) {
Context context = collection
.withDocumentClass(Context.class)
.aggregate(ImmutableList.of(
match(eq("stackId", aStackId)),
sort(descending("createTime")),
limit(1),
replaceRoot("$context")
))
.first();
if (context != null) {
return context;
}
return null;
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence
private static Bson createTertiaryMatchStage(final Criteria filterCriteria,
final Predicate authorizationSubjectsPredicate) {
final Criteria thingV1Criteria = CRITERIA_FACTORY.fieldCriteria(
new SimpleFieldExpressionImpl(FIELD_GRANTS), CRITERIA_FACTORY.eq(null));
// ACL and global-READ are checked at the beginning.
// check policy entries here, let ACL and global-Read fall through.
final Criteria internalGrCriteria = CRITERIA_FACTORY.existsCriteria(
new SimpleFieldExpressionImpl(FIELD_INTERNAL_GLOBAL_READS));
final Criteria internalAclCriteria = CRITERIA_FACTORY.existsCriteria(
new SimpleFieldExpressionImpl(FIELD_INTERNAL_ACL));
return match(or(
CreatePolicyRestrictionBsonVisitor.apply(filterCriteria, authorizationSubjectsPredicate)
.orElse(new BsonDocument()),
CreateBsonVisitor.apply(thingV1Criteria),
CreateBsonVisitor.apply(internalGrCriteria),
CreateBsonVisitor.apply(internalAclCriteria)));
}
代码示例来源:origin: eclipse/ditto
private static Bson createTertiaryMatchStage(final Criteria filterCriteria,
final Predicate authorizationSubjectsPredicate) {
final Criteria thingV1Criteria = CRITERIA_FACTORY.fieldCriteria(
new SimpleFieldExpressionImpl(FIELD_GRANTS), CRITERIA_FACTORY.eq(null));
// ACL and global-READ are checked at the beginning.
// check policy entries here, let ACL and global-Read fall through.
final Criteria internalGrCriteria = CRITERIA_FACTORY.existsCriteria(
new SimpleFieldExpressionImpl(FIELD_INTERNAL_GLOBAL_READS));
final Criteria internalAclCriteria = CRITERIA_FACTORY.existsCriteria(
new SimpleFieldExpressionImpl(FIELD_INTERNAL_ACL));
return match(or(
CreatePolicyRestrictionBsonVisitor.apply(filterCriteria, authorizationSubjectsPredicate)
.orElse(new BsonDocument()),
CreateBsonVisitor.apply(thingV1Criteria),
CreateBsonVisitor.apply(internalGrCriteria),
CreateBsonVisitor.apply(internalAclCriteria)));
}
内容来源于网络,如有侵权,请联系作者删除!