MongoDB is a big data architecture based on the NoSQL model that is neither relational nor SQL-based. We provide a connector that allows reports to use MongoDB as a data source. Reports based on a MongoDB data source can be used as Topics that allow users to create Ad Hoc views based on the fields returned by the MongoDB query.
As with all big data stores, MongoDB data sources have the following limitations and usage guidelines within JasperReports Server:
| • | MongoDB data sources are not supported for OLAP connections |
| • | MongoDB data sources can be used in Ad Hoc Topics, but they do not support query optimization. |
| • | You must configure your JVM memory to handle the expected amount of data (see the JasperReports Server Installation Guide). |
To create a MongoDB data source:
| 1. | Log on as an administrator. |
| 2. | Click View > Repository, expand the folder tree, and right-click a folder to select Add Resource > Data Source from the context menu. Alternatively, you can select Create > Data Source from the main menu on any page and specify a folder location later. If you have installed the sample data, the suggested folder is Data Sources. The New Data Source page appears. |
| 3. | In the Type field, select MongoDB Data Source. The information on the page changes to reflect what’s needed to define a MongoDB data source. |
You have the option to use attributes in the values of data source parameters. See Attributes in Data Source Definitions.
![js-DataSource-MongoDB.png.89622856b8bf12ee175e1c89cb09b56d.png](https://community.jaspersoft.com/applications/core/interface/js/spacer.png) |
MongoDB Data Source Page |
| 4. | Fill in the required fields, along with any optional information. |
The MongoDB URI has the form: mongodb://<hostname>:27017/<database>
| 6. | Click Test Connection to validate the data source. |
| 7. | When the test is successful, click Save. The Save dialog appears. |
| 8. | Enter a name for the data source and an optional description. The Resource ID is generated from the name you enter. If you haven't already specified a location, expand the folder tree and select the location for your data source. |
| 9. | Click Save in the dialog. The data source appears in the repository. |
MongoDB is designed to be accessed through API calls in an application or a command shell. As a consequence, it does not have a defined query language. In order to write queries for MongoDB data sources, we have developed a query language based on the JSON-like objects upon which MongoDB operates. JSON is the JavaScript Object Notation, a textual representation of data structures that is both human- and machine-readable.
The Jaspersoft MongoDB Query Language is a 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. The following examples give an overview of the Jaspersoft MongoDB Query Language, with SQL-equivalent terms in parentheses:
| • | Retrieve all documents (rows) in the given collection (table): |
| • | From all documents in the given collection, select the named fields (columns) and sort the results: |
| • | Retrieve only the documents (rows) in the given collection (table) that match the query (where clause). In this case, the date is greater-than-or-equal to the input parameter, and the name matches a string (starts with N): |
The Jaspersoft MongoDB Query Language also supports advanced features of MongoDB such as map-reduce functions and aggregation that are beyond the scope of this document. For more information, see the language reference on the Community website.
Recommended Comments
There are no comments to display.