-
Notifications
You must be signed in to change notification settings - Fork 436
Description
Version checked: 11.1.7
ES version: 7.16
Issue location: ElasticsearchClient.maping(String index)
When using data-streams the ElasticsearchSinkTask.tryWriteRecord(SingRecord sinkRecord, OffsetState offsetState) will first check if there are any predefined mappings for the index in ES and if not, kafka-connect-elasticsearch will try to create explicit mappings based on the schema of the record. This works fine with normal indicies but fails when we use data-streams in ES. The call in ElasticsearchClient.mapping(String index) succeeds, but it returns the actual [backing indicies|https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams.html#backing-indices] which have different names than the index that we are checking (the name of the datastream). This in turn causes the simple HashMap search in ElasticsearchClient.mapping(String index) to return null. As a result, kafka-connect-elasticsearch never finds any preexisting mappings in ES for the index and will try to create new explicit mappings and make it impossible to redefine or manage them from ES.
As a side note - I haven't tested it properly, but it looks like the check will fail in the same way when aliases are used in ES (data-streams are a kind of an alias)