Elastic exported: tried to parse field [payload] as object, but found a concrete value

Error I get in zeebe broker:

2020-05-30 06:27:53.874 [Broker-0-Exporter-1] [Broker-0-zb-fs-workers-0] WARN  io.zeebe.broker.exporter.elasticsearch - Failed to flush at least one bulk request ElasticsearchException[Elasticsearch exception [type=mapper_parsing_exception, reason=object mapping for [value.customHeaders.payload] tried to parse field [payload] as object, but found a concrete value]]
zeebe            | 2020-05-30 06:27:53.874 [Broker-0-Exporter-1] [Broker-0-zb-fs-workers-0] WARN  io.zeebe.broker.exporter.elasticsearch - Failed to flush bulk completely
zeebe            | 2020-05-30 06:27:54.295 [GatewayLongPollingJobHandler] [Broker-0-zb-actors-1] DEBUG io.zeebe.gateway - Remove blocking request BrokerActivateJobsRequest{requestDto={"type":"lwm2mApiCall","worker":"b90523e4-68e4-4652-b476-7cdd52d80250","timeout":1200000,"maxJobsToActivate":132,"jobKeys":[],"jobs":[],"variables":[],"truncated":false}} for job type lwm2mApiCall after timeout of PT30S

I am using customHeaders and have a ‘payload’ custom header in several tasks, with different values, sometimes it’s a simple text string, sometimes it’s a string containing json

My guess is the elasticsearch is not handling this, as it is applying parsing on what should really be a simple string. This decision is left to elastic, which creates the mapping by guessing the types

Is there any way around it?
E.g. can zeebe exporter be configured with the desired mapping ?

@philipp.ossler any ideas about this? I am not entirely sure that we have something to get around that problem now. @Eetay but I totally recommend to open an issue and link it here in the question.

Created: https://github.com/zeebe-io/zeebe/issues/4640

P.S. it is VERY useful to have elastic parse all the variables and headers of jobs, as this means they can be searched. A solution to this problem should ideally not disable this feature, but maybe offer an override, e.g. by allowing initial mapping to be provided by user