1

我试图创建此查询与碧玉报告中使用,但东西是错误与我的语法,我有2个ISODates在我的数据库,我想接着之间进行查询,在该查询我用$match$gt$lt蒙戈查询日期范围ISODate格式

反正因为控制台说错误,但不`吨指定它的东西是不正确的。

Obs:问题与$match$lt$gt.有关,因为没有它们就有可能进行查询。

代码:

{ 
    runCommand : { 
     aggregate : 'saleCalculation', 
     pipeline : [ 
      { 
       $match: { 
        processingInfo.modifiedDate: {$gt : ISODate("2016-05-01T09:29:40.572Z")}, 
        {$lt : ISODate("2016-06-01T09:29:40.572Z")} 
       } 
      },   
      { 
       $project : { 
        header.documentCode : 1, 
        header.transactionDate : 1, 
        header.metadata.entityName : 1, 
        lines : 1 
       } 
      }, 
      { $unwind : '$lines'}, 
      { $unwind :'$lines.calculatedTax.details' } 
     ] 
    } 
} 

碧玉手册说,我需要做这样的事情:

http://community.jaspersoft.com/wiki/how-query-mongo-isodate-data-parameter

,但我不明白,

回答

0

试试这个代码:

{ 
    runCommand : { 
     aggregate : 'saleCalculation', 
     pipeline : [ 
      { 
       $match: { 
        processingInfo.modifiedDate: {$gt : ISODate("2016-05-01T09:29:40.572Z"), 
        $lt : ISODate("2016-06-01T09:29:40.572Z")} 
       } 
      },   
      { 
       $project : { 
        header.documentCode : 1, 
        header.transactionDate : 1, 
        header.metadata.entityName : 1, 
        lines : 1 
       } 
      }, 
      { $unwind : '$lines'}, 
      { $unwind :'$lines.calculatedTax.details' } 
     ] 
    } 
} 
+0

没有合作;( – michelpm1

+0

你得到任何错误 – bhuvnesh

+0

是jsonparser错误 – michelpm1

0

尝试使用这条管道。确保使用双引号。

[ 
     { "$match": {"processingInfo.modifiedDate": { "$gt":ISODate("2010-03-26T18:40:59.000Z"), "$lt":ISODate("2016-09-28T18:40:59.000Z")}}}, 
     { 
      "$project" : { 
       "header.documentCode": 1, 
       "header.transactionDate": 1, 
       "header.metadata.entityName": 1, 
       "lines" : 1 
      } 
     }, 
     { "$unwind": "$lines"}, 
     { "$unwind": "$lines.calculatedTax.details" } 
    ] 

我在mongo shell上试过这个命令,它没有任何错误地工作。

db.runCommand({"aggregate": "saleCalculation", "pipeline" : [ 
     { "$match": {"processingInfo.modifiedDate": { "$gt":ISODate("2010-03-26T18:40:59.000Z"), "$lt":ISODate("2016-09-28T18:40:59.000Z")}}}, 
     { 
      "$project" : { 
       "header.documentCode": 1, 
       "header.transactionDate": 1, 
       "header.metadata.entityName": 1, 
       "lines" : 1 
      } 
     }, 
     { "$unwind": "$lines"}, 
     { "$unwind": "$lines.calculatedTax.details" } 
    ] 
})