gpt4 book ai didi

Java/MongoDB - 如何解决错误 "exception: pipeline element 0 is not an object"

转载 作者:可可西里 更新时间:2023-11-01 09:41:55 24 4
gpt4 key购买 nike

我正在使用 aggregate() 方法并在游标中查找我正在使用以下代码的结果

                 dbObjArray = new BasicDBObject[2]
dbObjArray[0]= cruxLevel
dbObjArray[1] = project
// dbObjArray[2] = out
List<DBObject> pipeline = Arrays.asList(dbObjArray)
if (!datasetObject?.isFlat && jsonFor != 'collection-grid') {
println '-------------------------------- inside if block bbb--------------------------------------'
output= dataSetCollection.aggregate(pipeline)
}else{

/*DBObject out = new BasicDBObject('$out':"datasetTemp");
def db = getDB()*/

println '-------------------------------- inside else block--------------------------------------'

AggregationOptions aggregationOptions = AggregationOptions.builder()
.batchSize(100)
.outputMode(AggregationOptions.OutputMode.CURSOR)
.allowDiskUse(true)
.build();

output = dataSetCollection.aggregate(project)
}

我遇到了错误。

com.mongodb.CommandFailureException: { "serverUsed" : "127.0.0.1:15847" , "errmsg" : "exception: pipeline element 0 is not an object" , "code" : 15942 , "ok" : 0.0}

我哪里出错了,请帮忙!

谢谢。

最佳答案

def dbObjArray = new BasicDBObject[1]
dbObjArray[0]= project
List<DBObject> flatPipeline = Arrays.asList(dbObjArray)

AggregationOptions aggregationOptions = AggregationOptions.builder()
.batchSize(100)
.outputMode(AggregationOptions.OutputMode.CURSOR)
.allowDiskUse(true)
.build();
def cursor = dataSetCollection.aggregate(flatPipeline,aggregationOptions)

关于Java/MongoDB - 如何解决错误 "exception: pipeline element 0 is not an object",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33208640/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com