MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

MongoDB kafka source connector How can I support specific set of collections?

How can I support specified list of collections sync using mongodb to kafka source connector

You can filter specific collections using pipeline command:

 {
    "config": {
        "collection": "",
        "connection.uri": "mongodb://mongo1:27017,mongo2:27017,mongo3:27017",
        "connector.class": "com.mongodb.kafka.connect.MongoSourceConnector",
        "database": "test",
        "name": "mongo-source",
        "pipeline": "[   { $match: { \"ns.coll\": { \"$in\": [\"test1\" ,\"test2\" ] } } } ]",
        "tasks.max": "1",
        "topic.prefix": "mongo"
    },
    "name": "mongo-source",
    "tasks": [
        {
            "connector": "mongo-source",
            "task": 0
        }
    ],
    "type": "source"
}