简体   繁体   English

Kafka Elasticsearch 连接器时间戳

[英]Kafka Elasticsearch Connector Timestamps

I can see this has been discussed a few times here for instance but I think the solutions are out of date due to breaking changes in Elasticsearch.例如,我可以看到这里已经讨论过几次但我认为由于 Elasticsearch 中的重大变化,这些解决方案已经过时。

I'm trying to convert a long/epoch field in my Json in my Kafka topic to an Elasticsearch date type which is pushed through the connector.我正在尝试将我的 Kafka 主题中的 Json 中的 long/epoch 字段转换为通过连接器推送的 Elasticsearch 日期类型。

When I try to add a dynamic mapping, my Kafka connect updates fail because Im trying to apply two mappings to a field, _doc and kafkaconnect.当我尝试添加动态映射时,我的 Kafka 连接更新失败,因为我尝试将两个映射应用于字段,_doc 和 kafkaconnect。 This was a breaking change around version 6 I believe where you can only have one mapping per index.这是版本 6 的一项重大更改,我相信每个索引只能有一个映射。

{
    "index_patterns": [ "depart_details" ],
  "mappings": {
    "dynamic_templates": [
      {
        "scheduled_to_date": {
          "match":   "scheduled",
          "mapping": {
            "type": "date"
          }
        }
      } 
    ]
}}

I've now focussed on trying to translate the message at source in the connector by changing the field to a timestamp, time or date.我现在专注于尝试通过将字段更改为时间戳、时间或日期来从连接器中的源翻译消息。

    "transforms.TimestampConverter.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
        "transforms.TimestampConverter.field" : "scheduled",
        "transforms.TimestampConverter.target.type": "Timestamp"

However, any messages I try to send through this transformer fail with但是,我尝试通过此转换器发送的任何消息都失败了

Caused by: org.apache.kafka.connect.errors.DataException: Java class class java.util.Date does not have corresponding schema type.
    at org.apache.kafka.connect.json.JsonConverter.convertToJson(JsonConverter.java:604)
    at org.apache.kafka.connect.json.JsonConverter.convertToJson(JsonConverter.java:668)
    at org.apache.kafka.connect.json.JsonConverter.convertToJsonWithoutEnvelope(JsonConverter.java:574)
    at org.apache.kafka.connect.json.JsonConverter.fromConnectData(JsonConverter.java:324)
    at io.confluent.connect.elasticsearch.DataConverter.getPayload(DataConverter.java:181)
    at io.confluent.connect.elasticsearch.DataConverter.convertRecord(DataConverter.java:163)
    at io.confluent.connect.elasticsearch.ElasticsearchWriter.tryWriteRecord(ElasticsearchWriter.java:285)
    at io.confluent.connect.elasticsearch.ElasticsearchWriter.write(ElasticsearchWriter.java:270)
    at io.confluent.connect.elasticsearch.ElasticsearchSinkTask.put(ElasticsearchSinkTask.java:169)

Seems like a really common thing to need to do, but I don't see how to get a date or time field into Elastic through this connector in version 7?似乎需要做一件很常见的事情,但我看不到如何通过版本 7 中的此连接器将日期或时间字段输入 Elastic?

The Confluent documentation states that the ES connector is currently not supported with ES 7. Confluent 文档指出,ES 7 当前不支持ES 连接器。

According to this issue , it might suffice to change type.name=kafkaconnect to type.name=_doc in your connector configuration.根据这个问题,在您的连接器配置type.name=_doc type.name=kafkaconnect可能就足够了。

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

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