0
我正在使用Pentaho針對MongoDB進行報告。在改造我的查詢是一個聚合管道,如下所示:在針對MongoDB的Pentaho報告中使用ObjectId參數
[
{$match: {billing_cycle_id: "${billing_cycle}"} },
{
$project : {
account_id : 1,
age_120.cents : 1,
age_60.cents : 1,
age_30.cents: 1,
balance.cents: 1,
billing_cycle_id : 1,
transaction_line_items : 1
}
},
{$unwind : "$transaction_line_items"}
]
的$ {billing_cycle}默認值是5162f1c0b7228a2793000011
因此,這裏是從Pentaho的日誌查詢:
2013/12/12 09:57:12 - MongoDB Input.0 - Query pulled data from: [
2013/12/12 09:57:12 - MongoDB Input.0 - {$match: {billing_cycle_id: "5162f1c0b7228a2793000011"} },
2013/12/12 09:57:12 - MongoDB Input.0 - {
2013/12/12 09:57:12 - MongoDB Input.0 - $project : {
2013/12/12 09:57:12 - MongoDB Input.0 - account_id : 1,
2013/12/12 09:57:12 - MongoDB Input.0 - age_120.cents : 1,
2013/12/12 09:57:12 - MongoDB Input.0 - age_60.cents : 1,
2013/12/12 09:57:12 - MongoDB Input.0 - age_30.cents: 1,
2013/12/12 09:57:12 - MongoDB Input.0 - balance.cents: 1,
2013/12/12 09:57:12 - MongoDB Input.0 - billing_cycle_id : 1,
2013/12/12 09:57:12 - MongoDB Input.0 - transaction_line_items : 1
2013/12/12 09:57:12 - MongoDB Input.0 - }
2013/12/12 09:57:12 - MongoDB Input.0 - },
2013/12/12 09:57:12 - MongoDB Input.0 - {$unwind : "$transaction_line_items"}
2013/12/12 09:57:12 - MongoDB Input.0 - ]
我猜問題是,這不會返回任何數據,因爲billing_cycle_id是一個ObjectId,但當我將查詢更改爲
[
{$match: {billing_cycle_id: ObjectId("${billing_cycle}")} },
{
$project : {
account_id : 1,
age_120.cents : 1,
age_60.cents : 1,
age_30.cents: 1,
balance.cents: 1,
billing_cycle_id : 1,
transaction_line_items : 1
}
},
{$unwind : "$transaction_line_items"}
]
Pentaho在查詢中出錯。如何在參數中成功使用ObjectId?