问题描述
我有一个名为 Stock_Data_Revise_Nyse
的集合,其中包含一些相关数据,我使用jasper ireporter进行报告但是当我执行此给定查询时,它只返回值具有适当值和休息的字段 _id.Date,_id.Stock
返回 null
。
此查询在 Mongo Shell 中运行良好。
注意到: - 如果我使用单组,那么聚合在Jasper中运行正常,但是当我使用双组时,就像我在这里使用的那样,它为该字段返回null。 / p>
我搜索了很多论坛但很难找到任何答案。
任何类型的帮助都会受到赞赏。
{runCommand:{
aggregate:Stock_Data_Revise_Nyse,
pipe:[
{$ project:{Symbol_1:1,Name:1,Change:1,Date:{$ substr:[$ UTC_Timestmp,0,10]}}},
{$ match:{ 日期:16-01-2013}},
{$ group:{
_id:{Date:$ Date,Stock:$ Symbol_1},
value :{$ sum:$ Change}
}},
{$ sort:{value: - 1}},
{$ limit:5}
]
}}
这是因为你'重新使用旧版本的MongoDB Connector(v0.5.0,这是。
下载 v2.0.1或更高版本,然后使用附带的文件 plugins / com.jaspersoft.studio.data.mongodb_2.0.1.jar
作为替换旧MongoDB Connector v0.5.0的依赖项。
您也可以使用Maven获取此工件(我们Bippo / Soluvas仅提供托管Maven存储库中常用文件的服务):
<依赖性>
< dependency>
< groupId> com.jaspersoft< / groupId>
< artifactId> com.jaspersoft.studio.data.mongodb< / artifactId>
< version> 2.0.1< / version>
< / dependency>
< / dependencies>
...
< repositories>
< repository>
< id> bippo-nexus-public< / id>
< url> http://nexus.bippo.co.id/nexus/content/groups/public/< / url>
< / repository>
< / repositories>
I have a collection named Stock_Data_Revise_Nyse
which has some relevant data and i am making reports using jasper ireporter but when i execute this given query it only returns me value field with appropriate value and rest _id.Date,_id.Stock
returns null
.
This query is running perfectly fine in Mongo Shell.
noticed:- If i use single group by then aggregation works fine in Jasper but when i use double group by like i have used here it returns null for that field.
I have searched many forums but hardly found any answer.
Any Kind Of Help Would Be Appreciated.
{ runCommand: {
aggregate : "Stock_Data_Revise_Nyse",
pipeline : [
{$project:{Symbol_1:1,Name:1,Change:1,Date:{$substr:["$UTC_Timestmp",0,10]}}},
{$match:{"Date":"16-01-2013"}},
{$group:{
_id:{Date:"$Date",Stock:"$Symbol_1"},
value:{$sum:"$Change"}
}},
{$sort:{"value":-1}},
{$limit:5}
]
}}
This is because you're using an old version of MongoDB Connector (v0.5.0, which is the only version available on MongoDB Connector download page).
Download JasperSoft Studio v2.0.1 or later, then use the included file plugins/com.jaspersoft.studio.data.mongodb_2.0.1.jar
as your dependency to replace the old MongoDB Connector v0.5.0.
You can also get this artifact using Maven (we Bippo/Soluvas are only providing the service to host commonly needed files in a Maven repository):
<dependencies>
<dependency>
<groupId>com.jaspersoft</groupId>
<artifactId>com.jaspersoft.studio.data.mongodb</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
...
<repositories>
<repository>
<id>bippo-nexus-public</id>
<url>http://nexus.bippo.co.id/nexus/content/groups/public/</url>
</repository>
</repositories>
这篇关于在聚合框架中使用mongodb的jasper报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!