gpt4 book ai didi

elasticsearch - 尝试使用Kafka Connect在Elasticsearch中为Kafka主题编制索引

转载 作者:行者123 更新时间:2023-12-02 22:48:20 25 4
gpt4 key购买 nike

我想将kafka中的主题以avro索引为elasticsearch格式,但是
我的时间戳记字段存在问题,无法识别
elasticsearch作为日期格式字段。

我对连接器使用了以下配置。

   {
"name": "es-sink-barchart-10",
"config": {
"connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",
"value.converter": "io.confluent.connect.avro.AvroConverter",
"key.converter": "io.confluent.connect.avro.AvroConverter",
"key.converter.schema.registry.url": "http://localhost:8081",
"value.converter.schema.registry.url": "http://localhost:8081",

"connection.url": "http://localhost:9200",

"type.name":"type.name=kafka-connect",

"topics": "exchange_avro_01",

"topic.index.map": "exchange_avro_01:exchange_barchart",

"key.ignore": "true"
}
}

原始字段是bigint类型,我希望目标字段是具有Elasticsearch的任何有效格式的日期类型。我定义了一个动态模板,尝试通过以下方式解决它:
curl -XPUT "http://localhost:9200/_template/kafkaconnect/" -H 'Content-Type: application/json' -d'
{
"index_patterns": "exchange*",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"kafka-connect": {
"dynamic_templates": [
{
"dates": {
"match_mapping_type": "long",
"match": "TIME",
"mapping": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
}
]
,
"properties": {
"CLOSE": {
"type": "double"
},
.
.
.
}
}

}
}
}'

当我加载上述连接器时,没有任何东西索引到elasticsearch。

有什么帮助吗?

最佳答案

如果您的来源是bigint,那么大概是一个时代。如果是一个纪元,那么这将不起作用:

"mapping": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}

因为您要告诉Elasticsearch日期格式为 yyyy-MM-dd HH:mm:ss(不是)。

因此,请尝试以下操作(暂时省略您的自定义映射;首先使它工作,然后再添加回去):
{
"index_patterns": "exchange*",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"kafka-connect": {
"dynamic_templates": [
{
"dates": {
"match": "TIME",
"mapping": {
"type": "date"
} } } ] } } }

另请引用: https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-field-mapping.html#date-detection

nothing is indexed to elasticsearch.



检查Kafka Connect工作程序日志和Elasticsearch日志是否有任何错误。

关于elasticsearch - 尝试使用Kafka Connect在Elasticsearch中为Kafka主题编制索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53323383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com