Jump to content
We've recently updated our Privacy Statement, available here ×

Join two collections in mongodb in Jasper


vivek.agarwal

Recommended Posts

  • 1 month later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

To connect to multiple datasources, Jasper offers virtual data source. The function, however, is provided only in the commercial or higher version and probably won’t appear in a free version. In addition, it supports connecting to only two datasources.


 


But you can try using esProc to assist Jasper to join the two collections. Suppose to select orders during a certain time period from collection sales and create a left join with collection emp. You can do it in esProc as follows:


A1=MongoDB("mongo://localhost:27017/test?user=root&password=sa")


A2=A1.find("sales","{'$and':[{'OrderDate':{'$gte':'"+string(begin)+"'}},{'OrderDate':{'$lte':'"+string(end)+"'}}]}","{_id:0}").fetch()


A3=A1.find("emp",,"{_id:0}").fetch()


A4=A1.close()


A5=join@1(A2:sales,SellerId;A3:emp,EId)


A6=A5.new(sales.Client:Client,sales.Amount:Amount,sales.OrderDate:OrderDate,emp.Name:Name)


Jasper can connect to esProc through JDBC. The way it calls an esProc script is the same as that it calls the stored procedure. Please refer to http://blog.raqsoft.com/?p=2460 for details.


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...