Hello guys.
I’m newbie with Kafka Connect and I’m trying to convert data from postgres to mongoDB. When performing SINK to mongo, my _id key is looking like this
{
"_id": {
"id": "84dd4ad4-c773-4482-8e10-eb023a9c5c81"
},
"email": null,
"email_constraint": "3ba2c50a-1cb4-4b5d-b1a4-e621fda2fb5c",
"email_verified": false,
"enabled": true,
"federation_link": null,
"first_name": null,
"last_name": null,
"realm_id": "d8ba57ce-dc0e-48a5-b51f-923c47115afc",
"username": "admin",
"created_timestamp": 1672265987079,
"service_account_client_link": null,
"not_before": 0
}
I need to leave _id key as object
{
"_id": {
"$oid": "84dd4ad4-c773-4482-8e10-eb023a9c5c81"
},
"email": null,
"email_constraint": "3ba2c50a-1cb4-4b5d-b1a4-e621fda2fb5c",
"email_verified": false,
"enabled": true,
"federation_link": null,
"first_name": null,
"last_name": null,
"realm_id": "d8ba57ce-dc0e-48a5-b51f-923c47115afc",
"username": "admin",
"created_timestamp": 1672265987079,
"service_account_client_link": null,
"not_before": 0
}
I’m using these configurations for the sink
name = mongo-sink-from-postgresql
connector.class = com.mongodb.kafka.connect.MongoSinkConnector
task.max = 1
topics = postgres-server.public.user_entity
connection.uri = mongodb://root:root@mongodb/
database = keycloak
document.id.strategy = com.mongodb.kafka.connect.sink.processor.id.strategy.BsonOidStrategy
document.id.strategy.overwrite.existing = true
writemodel.strategy = com.mongodb.kafka.connect.sink.writemodel.strategy.ReplaceOneBusinessKeyStrategy
change.data.capture.handler = com.mongodb.kafka.connect.sink.cdc.debezium.rdbms.mysql.MysqlHandler
errors.log.enable = true
errors.log.include.messages = true
key.converter = org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable = false
thank you for help