Creating MongoDB Input Data Source
The MongoDB connector is an interface used to import MongoDB’s schema-less BSON documents into a table schema that Panopticon Streams can interpret and analyze. It uses many BSON structure types and MongoDB query features.
- In the New Data Source page, select Input > MongoDB in the Connector drop-down list.
- Enter the following properties:
Property Description URL
Enter either:
-
localhost if the database resides on the same computer, or
-
IP address and port of the computer where MongoDB is installed (e.g.,
192.168.1.1:27017). If no port is specified, the default is 27017.
User Id
The user Id that will be used to connect to MongoDB.
Password
The password that will be used to connect to MongoDB.
Authentication DB
The database where the user is created.
Database
The database that will be used.
Collection
The collection that will be used.
-
- To make the Query Document feature of MongoDB available in Panopticon, select Use Query Document.
The Plugin Settings pane updates to display the settings of this query option.
For the Method option, select any of the following values:
- Find (Default)
Allows you to fetch a document from a MongoDB collection.
Two more configurable settings are available:
NOTE: _id field is always displayed while executing the Find method. You can opt to set this field to 0 to hide it (e.g., {"_id":0}).
- Sort
Provide a JSON object that defines the sort criteria, then set the order to either 1 for ascending or -1 for descending (e.g., {"address.building":1}).
- Projection
Provide a JSON object to include or exclude from the result of the Find query.
For example, if a document has 9 documents and you only need to display 5, you can either:
- select 5 JSON objects, then set the limit value to 1 to display
{"cuisine":1, "grades":1, "restaurant_id":1, "name":1, "borough":1}
- select 4 JSON objects then set the limit value to 0 to hide
{"address.zipcode":0, "address.coord":0, "address.street":0, "address.building":0}
- select 5 JSON objects, then set the limit value to 1 to display
- Aggregate
Allows you to specify aggregation pipeline using multiple stages.
Python format of the pipeline query can be used, see Getting Started with Aggregation Pipelines in Python for more information. In addition, JSON style syntax with query contained in a JSON object can also be used.
See Query Documents for more information on the Query Documents feature on MongoDB.
- Sort
In addition, the MongoDB command line interface displays query operations with a JSON style syntax.
Enter your JSON query document. See http://docs.mongodb.org/manual/tutorial/query-documents/ for more information on the Query Documents feature on MongoDB.
For example, queries from the document look like this: db.inventory.find ( {type:"snacks"} ). The database and collection are already defined in the UI and the Find operation is handled in the code. You only need to enter the JSON query:
{"type":"snacks"}
For more advanced query, it must include surrounding curly braces as well as matching internal braces.
- Find (Default)
- Instead of using Use Query Document, select the Parameterize query option.
Click Fetch Parameters to populate the Parameter drop-down and select a value. Then select what column to filter on in the Filter By drop-down.
- Select either the period (.) or comma (,) as the Decimal Separator.
NOTE: Prepend 'default:' for the elements falling under default namespace.
- You can also opt to click
. A new row displays in the JSON list box. Enter the necessary information for each column.
Property Description Name
The column name of the source schema.
NOTE: It is recommended to name the column the same as its JSON path for clarity and uniformity.
Json Path
The JsonPath of the source schema.
Type
The data type of the column. Can be a Text, Numeric, or Time.
Date Format
The format when the data type is Time.
NOTE:
To parse and format times with higher than millisecond precision, the format string needs to end with a period followed by sequence of upper case S. There can be no additional characters following them.
For example: yyyy-MM-dd HH:mm:ss.SSSSSS
Structure
Used for more advanced features and are covered in the Row-Wise Array Expansion, Column-Wise Array Expansion, and Bson-Wise Array Expansion sections. Value is the default structure and will always display data regardless of actual structure.
Column Count
Enabled when Column-Expanded Array structure is selected.
Enter the number of columns for the plugin to generate as columns for that array.
Enabled
Determines whether the message field should be processed.
To delete a column, check its
or all the column entries, check the topmost
, then click
.
- Click
. The new data source is added in the Data Sources list.
(c) 2013-2024 Altair Engineering Inc. All Rights Reserved.