收藏 = c_1,c_2
我想在mongodb中使用 groovy语言执行查找操作。我成功创建了匹配,查找和项目操作。但是我在 AggregationOutput 中遇到错误。
c_1.insert(new BasicDBObject(["id" : 1, "name" : "abc", "lastName" : "kumar", "companyId": 10]))
c_2.insert(new BasicDBObject(["id" : 10, "companyName" : "Microsoft", "numEmployee" : 100 ]))
// Successfully created the $match operations
// Successfully created the $lookup operations
// Successfully created the $project operations
List<DBObject> pipeline = Arrays.asList(match, lookup, project);
AggregationOutput output = c_1.aggregate(pipeline);
错误:响应消息:javax.script.ScriptException:java.lang.IllegalArgumentException:参数数量错误
答案 0 :(得分:1)
public AggregationOutput aggregate(DBObject firstOp,
DBObject... additionalOps)
您无法将List传递给该函数,您需要执行以下操作:
AggregationOutput output = c_1.aggregate(pipeline.get(0), pipeline.get(1), pipeline.get(2));
查看How to Load Test MongoDB with JMeter文章,以了解有关使用JMeter进行MongoDB负载测试的更多信息。