1

我正在尝试使用 Mongo Scala 驱动程序在 MongoDB 中通过查找应用聚合,当我尝试获取结果时,我得到了盒装错误。

val query: AggregateObservable[Document] = collection.aggregate(Seq(
    lookup("training", "trainingId", "_id", "trainingsOutput"),
    lookup("certification", "trainingsOutput.certificationId", "name", "certificationOutput"),
    filter(Document("startDate" -> Document("$lte" -> new Date()),
      "endDate" -> Document("$gte" -> new Date()))),
    project(Document(trainingDataMap))))

val res: Future[Seq[JsValue]] = query.toFuture().map(x => x.map(x => Json.parse(x.toJson()).as[JsValue]))

我得到的错误,

20/05/19 03:41:28 ERROR yarn.ApplicationMaster: User class threw exception: java.util.concurrent.ExecutionException: Boxed Error

Caused by: java.lang.NoSuchMethodError: com.mongodb.internal.operation.AsyncOperations.aggregate(Ljava/util/List;Ljava/lang/Class;JJLjava/lang/Integer;Lcom/mongodb/client/model/Collation;Lorg/bson/conversions/Bson;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Boolean;Lcom/mongodb/client/model/AggregationLevel;)Lcom/mongodb/operation/AsyncReadOperation;
    at com.mongodb.async.client.AggregateIterableImpl.asAsyncReadOperation(AggregateIterableImpl.java:172)
    at com.mongodb.async.client.MongoIterableImpl.batchCursor(MongoIterableImpl.java:161)
    at com.mongodb.async.client.MongoIterableSubscription.requestInitialData(MongoIterableSubscription.java:46)
    at com.mongodb.async.client.AbstractSubscription.tryRequestInitialData(AbstractSubscription.java:151)
    ... 38 more

我正在为驱动程序使用以下依赖项,

compile group: 'org.mongodb.scala', name: 'mongo-scala-driver_2.11', version: '2.6.0'

我注意到的问题,每当我尝试使用 toFuture 获取结果,以便将 Observable[T] 转换为 Seq[JsValue] 时,我都会收到错误消息。

4

0 回答 0