I am writing a MongoDB query on ireport in which I have to join 4 different collections. As there are no joins in MongoDB, I am planning to go with mapReduce. The problem is that the MongoDB query syntax for jasper reports is different from usual MongoDB queries and I can't find anywhere mapReduce to join multiple tables in Jaspersoft syntax. Can anyone point me in the right direction?
Asked
Active
Viewed 1,521 times
2
-
Can you just run mongo shell commands from this software you're using? There is no 'join' function built into mongo, but you can just run a query like: db.collection1.find().forEach(function(doc){db.collection2.save(doc)}); And do this 3 times. See this similar question: http://stackoverflow.com/questions/5681851/mongodb-combine-data-from-multiple-collections-in-to-one-how – Tom Swifty Oct 09 '13 at 14:49
1 Answers
0
Had the same problem. Don't know if its a solution you can apply in your scenario but I used simple subreports passing joining field value to subreport and doing the separate query in there (something like DBRef).
First pass the joiningKey to subreport > "joiningKey"=$F{joiningKey} (remember to create this parameter in subreport).
Than in subreport you can do any query you want including search by id using the joinigKey: {'collectionName':'joinedCollection', 'findQuery':{'_id':{'$oid':'$P!{joiningKey}'}} }

wilq
- 1