简体   繁体   English

推送自己的ID。 融合Kafka Connect Elasticsearch Docker

[英]Push own id. Confluent kafka connect elasticsearch docker

I'm using confluentinc/cp-kafka-connect docker image. 我正在使用confluentinc / cp-kafka-connect docker映像。 I'm trying to send JSON file to kafka, with elasticsearch id. 我正在尝试使用Elasticsearch ID将JSON文件发送到kafka。

{"_id":10000725, "_source": {"createdByIdentity":"tu_adminn","createdBy":"Admin Testuser"}}

here is my connector 这是我的连接器

{
  "name": "test-connector",
  "config": {
    "connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",
    "tasks.max": "1",
    "topics": "andrii",
    "key.ignore": "false",
    "schema.ignore": "true",
    "connection.url": "http://elasticsearch:9200",
    "type.name": "test-type",
    "name": "elasticsearch-sink"
  }
}

When i'm using key.ignore = true it's generates some weird id. 当我使用key.ignore = true时,它会生成一些奇怪的ID。 How can i pass exactly my id and source? 如何准确传递我的ID和来源?

Per the docs : 根据文档

  • If you specify key.ignore=true then Kafka Connect will use a composite key of your message's kafka topic, partition, and offset -- this is the "weird id" that you're seeing. 如果指定key.ignore=true那么Kafka Connect将使用消息的kafka主题,分区和偏移量的组合键-这是您看到的“怪异ID”。

  • If you want to use your own ID for the created Elasticsearch document, you can set key.ignore=false and Kafka Connect will use the key of the Kafka message as the ID. 如果要为创建的Elasticsearch文档使用自己的ID,可以设置key.ignore=false并且Kafka Connect将使用Kafka消息密钥作为ID。

If your Kafka message does not have the appropriate key for what you want to do, you will need to set it. 如果您的Kafka消息没有所需的密钥,则需要对其进行设置。 One option is to use something like KSQL : 一种选择是使用类似KSQL的东西:

CREATE STREAM target AS SELECT * FROM source PARTITION BY _id

Disclaimer: I work for Confluent, the company behind the open-source KSQL project 免责声明:我为开源KSQL项目背后的公司Confluent工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM