【问题标题】:unable to map topics to specified index in kafka elasticsearch connector无法将主题映射到 kafka elasticsearch 连接器中的指定索引
【发布时间】:2020-02-15 13:08:17
【问题描述】:

试图将主题 "name: localtopic" 映射到索引 "name:indexoftopic" , 它在弹性搜索“localtopic 和 indexoftopic”中创建了两个新索引,并且主题数据仅在主题名称索引“localtopic”中可见,显示的连接器中没有错误(分布式模式)

我的配置是

 "config" : {
  "connector.class" : "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",
  "tasks.max" : "1",
  "topics" : "localtopic", 
  "topic.index.map" : "localtopic:indexoftopic",
  "connection.url" : "aws elasticsearch url",
  "type.name" : "event",
  "key.ignore" : "false",
  "schema.ignore" : "true",
  "schemas.enable" : "false",
  "transforms" : "InsertKey,extractKey",
  "transforms.InsertKey.type" : "org.apache.kafka.connect.transforms.ValueToKey",
  "transforms.InsertKey.fields" : "event-id",
  "transforms.extractKey.type" : "org.apache.kafka.connect.transforms.ExtractField$Key",
  "transforms.extractKey.field" : "event-id"
 }

index name:indexoftopic 是在 elasticsearch 中创建的,但是 index_name:localtopic 可以看到数据 kafkaversion:2.3 connectorversion:5 elasticsearchversion:3.2.0

即使在日志信息中——topics.regex = "",我也不知道他的选项,谁能建议。这个怎么用???

【问题讨论】:

  • 你不需要topics.regex,你已经有了topics...版本5,你的意思是5.0吗?

标签: elasticsearch apache-kafka apache-kafka-connect


【解决方案1】:

下面对我有用,但是,我只将 1 个主题映射到不同的索引名称

"transforms": "addSuffix",  
"transforms.addSuffix.type": "org.apache.kafka.connect.transforms.RegexRouter",
"transforms.addSuffix.regex": "topic1.*",
"transforms.addSuffix.replacement": "index1",

所以,使用上述转换任何主题,例如topic1, topic1-test, topic1<anystring> 将映射到index1

或者,您也可以使用主题名称替换,通过如下更改最后两行,这将选择

    "transforms.addSuffix.regex": "topic.*",
    "transforms.addSuffix.replacement": "index$1",

基本上,您可以使用正则表达式替换部分或完整的主题名称。

【讨论】:

    【解决方案2】:

    如果您查看配置选项,建议您改用 RegexRouter 转换

    topic.index.map

    此选项现已弃用。未来的版本可能会完全删除它。请使用单个消息转换,例如 RegexRouter,将主题名称映射到索引名称。

    【讨论】:

    • 如何使用Regex Router你可以指定,多个主题到同一个索引,例如:topic1:index,topic2:index,topic3:在regex router中这样的index
    • 我不知道。我会尝试这样的"type.name" : "index" ... "transforms.Regex.regex":"topic(.*)", ... ... "transforms.Regex.replacement":"topic" docs.confluent.io/current/connect/transforms/regexrouter.html
    • 真正的问题是为什么你有“topic1,topic2,topic3”?您当然可以使用分区而不是按顺序命名的主题吗?就个人而言,我对每个主题使用一个连接器定义,而不是对它们进行分组
    猜你喜欢
    • 2021-06-08
    • 2015-09-03
    • 2012-02-20
    • 1970-01-01
    • 1970-01-01
    • 2019-05-05
    • 2020-09-06
    • 2019-04-18
    • 1970-01-01
    相关资源
    最近更新 更多