Using Jaspersoft with MongoDB
-
Upload
mariano-luna -
Category
Technology
-
view
3.671 -
download
7
description
Transcript of Using Jaspersoft with MongoDB
Session Overview
What is MongoDB?
Connecting to MongoDB from JasperServer
The MongoDB Query Language
Using MongoDB in iReport
Using Adhoc with MongoDB
©2010 Jaspersoft Corporation. Proprietary and Confidential 2
What is MongoDB
MongoDB (from "humongous") is an open source document database written in C++.
MongoDB in a nutshell Document-Oriented Storage (JSON Documents) JSON-style documents with dynamic schemas offer simplicity and
power. Full Index Support. Index on any attribute, just like you're used to. Rich, document-based query language. Map/Reduce Flexible aggregation and data processing.
©2010 Jaspersoft Corporation. Proprietary and Confidential 3
The Jaspersoft MongoDB Query Language
©2010 Jaspersoft Corporation. Proprietary and Confidential 4
The Jaspersoft MongoDB Query Language is a JSON-style declarative language for specifying what data to retrieve from MongoDB. The connector converts this query into the appropriate API calls and uses the MongoDB Java connector to query the MongoDB instance.
There are two types of queries supported:
API driven queries: These queries rely on the mongo-java-driver support provided to query MongoDB.
Command driven queries: This queries allow the usage of MongoDB Aggregation Framework operators
Connecting Jaspersoft to MongoDB
©2010 Jaspersoft Corporation. Proprietary and Confidential 5
Creating a JasperServer Datasource
Setting connection URL
and (optional) authentication
mongodb://<SERVER>:<PORT>/<COLLECTION>
API Driven Queries
Querying Mongo form Jasper{ # The following parameter is mandatory. collectionName : myCollection Details, # The following parameters are optional findQuery : { Details }, findFields : { Details }, sort : {Details}, mapReduce : {Details}, limit : int Details, rowsToProcess : int Details}
©2010 Jaspersoft Corporation. Proprietary and Confidential 6
Command Driven Queries
Querying mongo form Jasper{ runCommand : { Command body }, # The following parameter is optional rowsToProcess : int Details}
Using runCommand to access the MongoDB aggregation framework
{ runCommand : { aggregate : COLLECTION_NAME, pipeline : [ List of aggregation operations ] }}
©2010 Jaspersoft Corporation. Proprietary and Confidential 7
Example Queries
Minimal{ 'collectionName' : 'accounts’ }
Filtered and parameterized{ 'collectionName' : 'accounts', 'findQuery' : { 'status_date' : { '$gte' : $P{StartDate} }, 'name' : { '$regex' : '^N', '$options' : '' } }}
©2010 Jaspersoft Corporation. Proprietary and Confidential 8
Example Queries
Specify the fields returned and sort the results{ 'collectionName' : 'accounts', 'findFields' : { 'name':1, 'phone_office':1, 'billing_address_city':1, 'billing_address_street':1, 'billing_address_country':1 }, 'sort' : { 'billing_address_country':-1, 'billing_address_city':1 }}
©2010 Jaspersoft Corporation. Proprietary and Confidential 9
Example Queries
Using the Aggregation { runCommand: { aggregate : 'zips', pipeline : [ { $group : { _id : '$state', population: { $sum : '$pop' } } }, { $sort : { population : -1 } } ]}
©2010 Jaspersoft Corporation. Proprietary and Confidential 10
Additional Resources
MongoDBhttp://www.mongodb.org/
MongoDB Documentationhttp://docs.mongodb.org/manual/
The Jaspersoft MongoDB Query Languagehttp://community.jaspersoft.com/wiki/jaspersoft-mongodb-query-language
Right Outer Join Blog - by Matt Dahlman http://mdahlman.wordpress.com/2011/09/02/simple-reporting-on-mongodb/
JasperReports Server Documentationhttp://community.jaspersoft.com/documentation/
©2010 Jaspersoft Corporation. Proprietary and Confidential 12