Connecting to MongoDB

Applicable to Sisense on Linux and Microsoft Windows

Sisense enables easy and quick access to databases, tables and views contained within MongoDB databases.

Sisense provides a MongoDB connector for the ElastiCube.

Note: Before connecting to MongoDB database with Sisense, note that MongoDB is an unstructured database, and therefore tables may be flattened with additional tables being created for nested items.

To connect to MongoDB:

  1. Open Sisense. For a non-local installation, open Sisense on the hosted cloud environment.
  2. In the Data page, open an ElastiCube or create a new ElastiCube.
  3. In the Model Editor, click . The Add Data dialog box is displayed.
  4. Click MongoDB to open the MongoDB settings.

    You can connect to MongoDB using either Basic or Advanced settings.
  5. Connecting to MongoDB: Basic Settings
    In the MongoDB settings area, enter the following information:
    Server: Enter IP address of the host where your MongoDB instance is running.
    Port: Enter the number of the TCP port that the server uses to listen for client connections.
    Database: Enter the name of the database that you want to access (case-sensitive).
    Replica Set: If you are connecting to a replica set in your MongoDB implementation, select the Replica Set checkbox and then do the following:
  6. Authentication Source: The authentication mechanism to use, No authentication, LDAP, or username and password.
    Enable SSL: Select to enable SSL.
    Metadata: This option specifies where the driver looks for the schema definition.
    Sampling Method: This property specifies whether the driver starts sampling data from the first or last record when generating a temporary schema definition.
  7. Connecting to MongoDB: Advanced Settings
    Advanced: Enter a JDBC connection string. You must provide the JDBC parameters as semicolon-separated key-value pairs. For example:
    jdbc:mongodb://[server];SSL=false;SamplingLimit=100;SamplingStepSize=1;SamplingStrategy=Forward;EnableUTCTimeZone=true

  8. Click Next. A list of tables in the database is displayed. All tables and views associated with the database will appear in a new window.
  9. From the Tables list, select the relevant table or view you want to work with. You can click next to the relevant table or click Preview to see a preview of the data inside it.
  10. (Optional) Click + to customize the data you want to import with SQL. See Importing Data with Custom Queries for more information.
  11. After you have selected all the relevant tables, click Done. The tables are added to your data model.

Connecting to MongoDB with a Schema Editor

If you have a large or complex MongoDB implementation, Sisense recommends connecting to your MongoDB via the Schema editor.

This procedure comprises two main steps:

Creating a Schema Definition JSON File

Use a Schema Editor to create a schema definition file in JSON format for your MongoDB.

For more information, see this article about using a schema editor, and the Schema Editor User Guide.

To create the schema:

  1. Download the attached SchemaEditor.jar file from here.
  2. On your computer, in the folder containing the SchemaEditor.jar file, open a command prompt.
  3. Run the following command:
    java -jar SchemaEditor.jar
  4. In the Schema Editor window, under “Create a new Schema Definition”, click Create New.
  5. In the Connection URL field, enter the connection string, and click Connect.
  6. Select the collections you want to use and click Sample.
  7. Add and remove columns as required.
  8. From the File menu, click Save to save the JSON file.

Connecting the Schema Definition JSON File to Sisense

Having created the schema definition JSON file, you can now connect it to Sisense. Doing so ensures that when you connect your MongoDB data source, the correct tables and columns are imported.

To connect the schema definition JSON file to Sisense:

  1. Open Sisense and, in your ElastiCube, from the Data page, click + Data.
  2. Add the MongoDB connector.
  3. In the Metadata Mechanism field, select Metadata file.
  4. In the Local Metadata File field, enter the path of the generated JSON file:
  5. Click Next and complete the wizard.

Connecting to MongoDB Atlas

MongoDB Atlas is a MongoDB cloud service. Sisense supports connections to MongoDB Atlas through the following methods:

Both methods are described below.

Prerequisites

MongoDB Atlas has the following prerequisites:

For more information, see https://docs.atlas.mongodb.com/connect-to-cluster/.

MongoDB Atlas Example Settings

The following is an example of a three node cluster in MongoDB Atlas. This example is used to describe what information you need to provide in Sisense to establish a connection with MongoDB Atlas in Connecting to MongoDB Atlas with the MongoDB Connector.

This example has three nodes:

The username and password are: admin/********.

The database to be accessed in this example is sample_airbnb.

Connecting to MongoDB Atlas with the MongoDB Connector

Using the example above, enter the connection details as follows in the MongoDB Connector settings:

Address:
Option 1:
Enter the hosts separated by comma. The port is taken from the Port field using it as a default port. Spaces are ignored.
cluster0-shard-00-00-l2zsn.mongodb.net, cluster0-shard-00-01-l2zsn.mongodb.net, cluster0-shard-00-02-l2zsn.mongodb.net
Option 2:
Enter the hosts with its port. The Port field is ignored. Spaces are ignored.
cluster0-shard-00-00-l2zsn.mongodb.net:27017, cluster0-shard-00-01-l2zsn.mongodb.net:27017, cluster0-shard-00-02-l2zsn.mongodb.net:27017

Port: Ignored if specified in the address, otherwise used as a default for every host without a port, 27017.

Database: sample_airbnb

Authentication mechanism: Username and password

Username: admin

Password: ********

Enable SSL:  Leave this checkbox empty as SSL is used for Atlas automatically.

After entering your credentials, you should then see your database.

Limitations

Troubleshooting MongoDB Connections