Skip to content
MongoDB interpreter for Apache Zeppelin
Java JavaScript
Branch: master
Clone or download
Latest commit f50d0a2 Jul 16, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
data Add example dataset + fix js issue + add unit tests Jun 21, 2016
docs Add files via upload Jul 16, 2018
src Upgrade to Zeppelin 0.7.0 Mar 20, 2017
.gitignore New param: authenticationDatabase Aug 25, 2016
LICENSE Initial commit Jun 19, 2016 Update Jul 16, 2018
pom.xml Upgrade to Zeppelin 0.7.0 Mar 20, 2017


MongoDB interpreter for Apache Zeppelin.

Supported versions of MongoDB: >= 3.0

If you are interested, there is a Docker image for Zeppelin with MongoDB interpreter:


Requirement: Zeppelin must be in your local repo.

mvn clean package


If you cannot build the jar, you can download it in the release page


  • Update $ZEPPELIN_HOME/conf/zeppeln-site.xml
  • Create $ZEPPELIN_HOME/interpreter/mongodb
  • Copy interpreter jar in $ZEPPELIN_HOME/interpreter/mongodb

In some cases, mongodb is not visible in the list of the available interpreters. In this case, after the previous steps, you can create a new interpreter and in the interpreter group selection, you should be able to select mongodb.



ParameterDefault valueDescription shell path command timeout of documents displayed in a table
mongo.server.databasetestMongDB database name
mongo.server.hostlocalhostHost of the MongDB server
mongo.server.port27017Port of the MongDB server
mongo.server.usernameUsername for authentication
mongo.server.passwordPassword for authentication
mongo.server.authentdatabaseDatabase used for authentication

How to use

In Zeppelin, use %mongodb in a paragraph. After that, you can type the same Javascript code you use when you write scripts for the Mongo shell. For more information, please consult:

There are several functions that have been added to help you in Zeppelin:

  • printTable(cursor, fields, flattenArray): to print a table (i.e. it uses %table). Arguments:
    • cursor: a DBQuery or DBCommandCursor instance
    • fields: an array of field names to put in the table (can be null)
    • flattenArray: if true, the arrays in the documents will also be flatten (false by default)
  • DBQuery.prototype.table: to print a table (it invokes the previous function)
  • DBCommandCursor.prototype.table: same as above



// Display a table
db.zipcodes.find({ "city":"CHICAGO", "state": "IL" }).table()

var states = db.zipcodes.aggregate( [
   { $group: { _id: "$state", totalPop: { $sum: "$pop" } } },
   { $match: { totalPop: { $lt: 1000*1000 } } },
   { $sort: { totalPop: 1 } }
] )

// Build a 'table'
print("%table state\ttotalPop")
states.forEach(state => { print(state._id + "\t" + state.totalPop) })


You can’t perform that action at this time.