简体   繁体   English

无法将主题映射到 kafka elasticsearch 连接器中的指定索引

[英]unable to map topics to specified index in kafka elasticsearch connector

tried to map topic "name: localtopic" to index "name:indexoftopic" , its creating two new index in elastic search "localtopic and indexoftopic" and data of topic visible only in topic name index "localtopic", no errors in connector shown ( distributed mode )尝试将主题 "name: localtopic" 映射到索引 "name:indexoftopic" ,它在弹性搜索 "localtopic 和 indexoftopic" 中创建了两个新索引,并且主题数据仅在主题名称索引 "localtopic" 中可见,显示的连接器中没有错误(分布式模式)

my config is我的配置是

 "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 is created in elasticsearch but data is seen by index_name:localtopic kafkaversion:2.3 connectorversion:5 elasticsearchversion:3.2.0索引名称:indexoftopic 是在 elasticsearch 中创建的,但是数据可以通过 index_name:localtopic kafkaversion:2.3 connectorversion:5 elasticsearchversion:3.2.0 看到

even in logs INFO -- topics.regex = "", I don't know ihis option, can anyone suggest.即使在日志信息中——topics.regex = "",我不知道他的选项,任何人都可以提出建议。 how to use this ???这个怎么用???

Below worked for me, but, I was mapping only 1 topic to a different index name下面对我有用,但是,我只将 1 个主题映射到不同的索引名称

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

so, with above transforms any topic such as topic1, topic1-test, topic1<anystring> will be mapped to index1因此,通过上述转换,任何主题(例如topic1, topic1-test, topic1<anystring>都将映射到index1

alternately, you can use the topic name in replacement as well, by changing the last 2 lines as below, this will pick或者,您也可以使用主题名称替换,通过如下更改最后两行,这将选择

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

basically, you can replace partial or full topic name using regex.基本上,您可以使用正则表达式替换部分或完整的主题名称。

It is advised that you use RegexRouter transform instead, if you look at the config options如果您查看配置选项,建议您改用 RegexRouter 转换

topic.index.map

This option is now deprecated.此选项现已弃用。 A future version may remove it completely.未来的版本可能会完全删除它。 Please use single message transforms, such as RegexRouter, to map topic names to index names.请使用单个消息转换,例如 RegexRouter,将主题名称映射到索引名称。

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

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