You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pentaho 9.4 MongoDB Input步骤JSONParseException报错求助

问题:MongoDB聚合查询在Pentaho 9.4中报JSONParseException
  • 在RobotMongo中可正常执行的聚合查询:
db.history.aggregate( [ { $match: {_insertedDate: {$gte:ISODate("2023-07-26T00:00:00Z")}} }, { $group:{_id:{originalSummary:"$originalSummary"}} } ] )
  • 将该查询放入Pentaho 9.4的MongoDB Input步骤时,触发JSONParseException,报错信息:
2023/07/26 19:54:36 - MongoDB input.0 - ERROR (version 9.4.0.0-343, build 0.0 from 2022-11-08 07.50.27 by buildguy) : org.pentaho.di.core.exception.KettleException: 
2023/07/26 19:54:36 - MongoDB input.0 - com.mongodb.util.JSONParseException: 
{ $match: {_insertedDate: {$gte: ISODate("2023-07-26T00:00:00Z")}} }
                                ^
2023/07/26 19:54:36 - MongoDB input.0 - 
{ $match: {_insertedDate: {$gte: ISODate("2023-07-26T00:00:00Z")}} }
                                ^
2023/07/26 19:54:36 - MongoDB input.0 - 
2023/07/26 19:54:36 - MongoDB input.0 -     at org.pentaho.di.trans.steps.mongodbinput.MongoDbInput.processRow(MongoDbInput.java:155)
2023/07/26 19:54:36 - MongoDB input.0 -     at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2023/07/26 19:54:36 - MongoDB input.0 -     at java.lang.Thread.run(Thread.java:745)
2023/07/26 19:54:36 - MongoDB input.0 - Caused by: com.mongodb.util.JSONParseException: 
{ $match: {_insertedDate: {$gte:ISODate("2023-07-26T00:00:00Z")}} }
                                ^
2023/07/26 19:54:36 - MongoDB input.0 -     at com.mongodb.util.JSONParser.parse(JSON.java:232)

问题原因

Pentaho的MongoDB Input步骤使用的严格JSON解析器不支持MongoDB Shell特有的ISODate()语法,该语法是Mongo Shell的扩展,不属于标准JSON范畴。

解决方法

将ISODate("2023-07-26T00:00:00Z")替换为标准JSON兼容的MongoDB日期扩展语法,同时确保所有键名用双引号包裹(严格JSON要求),修改后的聚合查询如下:

[
  { "$match": { "_insertedDate": { "$gte": { "$date": "2023-07-26T00:00:00Z" } } } },
  { "$group": { "_id": { "originalSummary": "$originalSummary" } } }
]

内容的提问来源于stack exchange,提问作者Fernando A.W.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 19:15:04