[英]Kafka connect elastic search ID creation for multiple fields not working
I am asking this question as there was no answer in the original case: Elastic Kafka Connector, ID Creation . 我问这个问题,因为在原始情况下没有答案: Elastic Kafka Connector,ID Creation 。
I have a similar situation. 我也有类似的情况。
Elastic search table to create a record for a single field, but not for multiple fields when request sent through kafkaconnect. 弹性搜索表,用于为通过kafkaconnect发送的请求为单个字段创建记录,但不为多个字段创建记录。
Getting exception "Key is used as document id and can not be null" in elastic search. 在弹性搜索中获取异常“密钥用作文档ID,不能为null” 。
My Connector Configurations: 我的连接器配置:
{
"name": "test-connector33",
"config": {
"connector.class":"io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",
"tasks.max": "1",
"topics": "test-connector33",
"connection.url": "http://localhost:9200",
"type.name": "aggregator",
"schema.ignore": "true",
"topic.schema.ignore": "true",
"topic.key.ignore": "false",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"value.converter.schemas.enable": "false",
"key.converter": "org.apache.kafka.connect.json.JsonConverter",
"key.converter.schemas.enable": "false",
"key.ignore":"false",
"name": "test-connector33",
"transforms": "InsertKey,extractKey",
"transforms.InsertKey.type":"org.apache.kafka.connect.transforms.ValueToKey",
"transforms.InsertKey.fields":"customerId,city",
"transforms.extractKey.type":"org.apache.kafka.connect.transforms.ExtractField$Key",
"transforms.extractKey.field":"customerId,city"
}}
Any idea how to resolve this? 任何想法如何解决这个问题?
Thanks in advance! 提前致谢!
org.apache.kafka.connect.transforms.ExtractField$Key
only supports single fields. org.apache.kafka.connect.transforms.ExtractField$Key
仅支持单个字段。
Pretend your JSON object was a HashMap<String, Object>
. 假设您的JSON对象是
HashMap<String, Object>
。 You cannot find the field customerId,city
, and so that map.get(field)
operation returns null
, therefore setting the field to be null. 您找不到字段
customerId,city
,因此map.get(field)
操作返回null
,因此将字段设置为null。
If you want to send keys via the console producer, you are welcome to do that by adding --property print.key=true
as a flag, then typing the key, press tab, then putting the value. 如果要通过控制台生产者发送密钥,欢迎这样做,方法是添加
--property print.key=true
作为标记,然后键入密钥,按Tab键,然后输入值。 If you want to echo data into the process, then you can also set --property key.separator='|'
如果要将数据回显到进程中,则还可以设置
--property key.separator='|'
, for a vertical bar as well as add --property parse.key=true
,用于竖线以及添加
--property parse.key=true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.