Elastic MongoDB connectoredit

The Elastic MongoDB connector is a native connector for MongoDB data sources.

Availability and prerequisitesedit

The MongoDB connector is available in Elastic versions 8.5.0+.

Currently, this connector is available in technical preview. Features in technical preview are subject to change and are not covered by the service level agreement (SLA) of features that have reached general availability (GA).

To use this connector, you must satisfy all prerequisites for native connectors. There are no additional prerequisites unique to this connector.

Usage and troubleshootingedit

To connect to a MongoDB data source, you will need the information described in MongoDB configuration. And the data source must satisfy the compatibility requirements described in MongoDB compatibility.

Otherwise, there are no instructions unique to this connector. Review the following documentation for native connectors:


The following sections describe technical details for this connector.

MongoDB compatibilityedit

The MongoDB connector is compatible with MongoDB Atlas and MongoDB 3.6+.

The MongoDB data source and your Elastic deployment must be able to communicate with each other over a network.

MongoDB configurationedit

When configuring an index for use with this connector, you will need to provide some or all of the following information about the data source.

MongoDB host

The URI of the host. Examples:

  • mongodb+srv://my_username:my_password@cluster0.mongodb.net/mydb?w=majority
  • mongodb://
Use direct connection (true/false)

Whether to use the direct connection option for the MongoDB client. Examples.

  • true
  • false
MongoDB username

The MongoDB username the connector will use.

The user must have access to the configured database and collection. You may want to create a dedicated, read-only user for each connector.

See Security for security details.

MongoDB password

The MongoDB password the connector will use.

See Security for security details.

MongoDB database

The MongoDB database to sync. The database must be accessible using the configured username and password.

See Security for security details.

MongoDB collection

The MongoDB collection to sync. The collection must exist within the configured database. The collection must be accessible using the configured username and password.

See Security for security details.

Elasticsearch documentsedit

All documents in the configured MongoDB database and collection are extracted and transformed into documents in your Elasticsearch index.

  • The connector creates one Elasticsearch document for each MongoDB document in the configured database and collection.
  • For each document, the connector transforms each MongoDB field into an Elasticsearch field.
  • For each field, Elasticsearch dynamically determines the data type.

This results in Elasticsearch documents that closely match the original MongoDB documents.

As soon as your first documents are synced, you can view the documents and inspect the mapping for the index. This will help you understand how your data is structured in Elasticsearch, and how this differs from the structure of the original MongoDB documents.


Users can launch a sync manually or schedule a recurring sync.

When you select the Sync button, the sync job has to wait until the connector picks up the task.

Each sync is a "full" sync. For each MongoDB document discovered:

  • If it does not exist, the document is created in Elasticsearch.
  • If it already exists in Elasticsearch, the Elasticsearch document is replaced and the version is incremented. See View documents.
  • If an existing Elasticsearch document no longer exists in the MongoDB collection, it is deleted from Elasticsearch.
  • Embedded documents are stored as an object field in the parent document. This is recursive, because embedded documents can themselves contain embedded documents.