Docs 菜单
Docs 主页
/
MongoDB Kafka Connector
/ /

接收连接器写入模型策略

在此页面上

  • Overview
  • Strategies

使用下表中的策略指定MongoDB Kafka接收器connector如何将数据写入MongoDB 。 您可以使用以下配置指定写入策略:

writemodel.strategy=<a writemodel strategy>

有关按类别整理的接收器Connector配置设置列表,请参阅有关接收器连接器配置属性的指南。

名称
说明
DefaultWriteModelStrategy

Description:
This strategy uses the ReplaceOneDefaultStrategy by default, and the InsertOneDefaultStrategy if you set the timeseries.timefield option.

This is the default value for the writemodel.strategy configuration setting.
InsertOneDefaultStrategy

Description:
Insert each sink record into MongoDB as a document.
Apply the following configuration to your sink connector to specify this setting:
writemodel.strategy=com.mongodb.kafka.connect.sink.writemodel.strategy.InsertOneDefaultStrategy
ReplaceOneDefaultStrategy

Description:
Replaces at most one document in MongoDB that matches a sink record by the _id field. If no documents match, insert the sink record as a new document.
Apply the following configuration to your sink connector to specify this setting:
writemodel.strategy=com.mongodb.kafka.connect.sink.writemodel.strategy.ReplaceOneDefaultStrategy
ReplaceOneBusinessKeyStrategy

Description:
Replaces at most one document that matches a sink record by a specified business key. If no documents match, insert the sink record as a new document.
Apply the following configuration to your sink connector to specify this setting:
writemodel.strategy=com.mongodb.kafka.connect.sink.writemodel.strategy.ReplaceOneBusinessKeyStrategy
To see an example showing how to use this strategy, see our guide on write model strategies.
DeleteOneDefaultStrategy

Description:
Deletes at most one document that matches your sink connector's key structure by the _id field only when the document contains a null value structure.
This is implicitly specified when you set mongodb.delete.on.null.values=true.
You can set this explicitly with the following configuration:
writemodel.strategy=com.mongodb.kafka.connect.sink.writemodel.strategy.DeleteOneDefaultStrategy
DeleteOneBusinessKeyStrategy

Description:
Deletes at most one MongoDB document that matches a sink record by a business key.
Apply the following configuration to your sink connector to specify this setting:
writemodel.strategy=com.mongodb.kafka.connect.sink.writemodel.strategy.DeleteOneBusinessKeyStrategy
To see an example showing how to use this strategy, see our guide on write model strategies.
UpdateOneTimestampsStrategy

Description:
Add _insertedTS (inserted timestamp) and _modifiedTS (modified timestamp) fields into documents.
Apply the following configuration to your sink connector to specify this setting:
writemodel.strategy=com.mongodb.kafka.connect.sink.writemodel.strategy.UpdateOneTimestampsStrategy
To see an example showing how to use this strategy, see our guide on write model strategies.
UpdateOneBusinessKeyTimestampStrategy

Description:
Add _insertedTS (inserted timestamp) and _modifiedTS (modified timestamp) fields into documents that match a business key.
Apply the following configuration to your sink connector to specify this setting:
writemodel.strategy=com.mongodb.kafka.connect.sink.writemodel.strategy.UpdateOneBusinessKeyTimestampStrategy

后退

Id 策略

在此页面上