# Kafka Connect Elastic Connector issue with updates

**URL:** <https://forum.confluent.io/t/kafka-connect-elastic-connector-issue-with-updates/2954>\
**Category:** Kafka Connect\
**Created:** [30 September 2021 23:50 UTC](https://forum.confluent.io/t/kafka-connect-elastic-connector-issue-with-updates/2954 "2021-09-30T23:50:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![murali](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@murali](https://forum.confluent.io/u/murali)\
**Post date:** [30 September 2021 23:50 UTC](https://forum.confluent.io/t/kafka-connect-elastic-connector-issue-with-updates/2954/1 "2021-09-30T23:50:48Z")

</div>

Hi i am using debezium mongo as a source and elastic sink connector. My inserts are working fine , but for updates since mongo only sends a patch with message structure as given below with only the columns that has changed , the elastic connector replaces the entire documented with only the fields in patch.

So if my initial json has 10 fields and if the updates comes with just 2 fields , the entire document gets replaced with 2 fields and rest of then are lost.

Is there a way to update the original document just for the 2 fields and leave the rest of the field as it is.

{“after”: null, “patch”: “{"$v": 1,"$set": {"orderMode": "ab"}}”, “filter”: “{"\_id": "38815002\_so\_us"}”, “source”: {“version”: “1.6.0.Final”, “connector”: “mongodb”, “name”: “cdc\_ordersdb”, “ts\_ms”: 1633042350000, “snapshot”: “false”, “db”: “orders”, “sequence”: null, “rs”: “s0”, “collection”: “test”, “ord”: 2, “h”: 1924224555192216145, “tord”: null, “stxnid”: null}, “op”: “u”, “ts\_ms”: 1633042350198, “transaction”: null}

Here is. my configuration  
{  
“name”: “sink\_order\_orderhistorydb\_elastic\_v2.test”,

```
  "connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",
  "topics": "cdc_ordersdb.orders.test",
  "tasks.max": "1",

  "connection.url": "xxx",
  "connection.username": "xxx",
  "connection.password": "xxx",

  "transforms": "unwrap,extractKey,dropPrefix",
  "transforms.unwrap.type": "io.debezium.transforms.UnwrapFromEnvelope",
  "transforms.unwrap.drop.tombstones": "false",
  "transforms.unwrap.delete.handling.mode": "drop",
  "transforms.unwrap.array.encoding": "document",
  
  "transforms.dropPrefix.regex": "(.*)\\.(.*)\\.(.*)",
  "transforms.dropPrefix.type": "org.apache.kafka.connect.transforms.RegexRouter",
  "transforms.dropPrefix.replacement": "cdc_$3",

  "transforms.extractKey.type" :"org.apache.kafka.connect.transforms.ExtractField$Key",
  "transforms.extractKey.field" :"id",

  "errors.log.enable": "true",
  "errors.tolerance": "all",
  "errors.log.include.messages": "true",
  "errors.deadletterqueue.topic.name": "__deadletter.sink_order_orderhistorydb_elastic_v2.test",
  "errors.deadletterqueue.topic.replication.factor": "3",
  "errors.deadletterqueue.context.headers.enable": "true",

  "value.converter.schemas.enable": "true",
  "value.converter": "io.confluent.connect.avro.AvroConverter",
  "value.converter.schema.registry.url": "xxx",
  "key.converter": "io.confluent.connect.avro.AvroConverter",
  "key.converter.schemas.enable": "true",
  "key.converter.schema.registry.url": "xxx",

  "behavior.on.null.values": "DELETE",
  "behavior.on.malformed.documents": "WARN",
  "write.method": "UPSERT",

  "key.ignore": "false",
  "schema.ignore": "true",
  "consumer.override.max.partition.fetch.bytes":"20971520",

  "read.timeout.ms": "60000",
  "batch.size": "2000"

```

}

---

<div class="post-metadata">

**Author:** ![riferrei](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/riferrei/32/1848_2.png) [@riferrei](https://forum.confluent.io/u/riferrei)\
**Post date:** [1 October 2021 14:57 UTC](https://forum.confluent.io/t/kafka-connect-elastic-connector-issue-with-updates/2954/2 "2021-10-01T14:57:02Z")

</div>

Can you, please, provide an example of how the document on Elasticsearch looks like?

I have the feeling that this is happening because you are sending the documents AS-IS from what Debezium delivers to the Kafka topic. Given Elasticsearch’s immutable nature, a complete replacement is occurring. If this is the case, you might need to implement a transformation layer between Kafka and Elasticsearch — using either SMT’s or maybe ksqlDB to produce a well-formed document.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [31 October 2021 14:57 UTC](https://forum.confluent.io/t/kafka-connect-elastic-connector-issue-with-updates/2954/3 "2021-10-31T14:57:53Z")

</div>

Closed on 31 October 2021 14:57 UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
