title: Kafka Confluent cloud ElasticsearchSink Connector: Mapping collision in index
body: <p>I have Kafka running on confluent cloud where I can produce data with a Node.js client, data is sent as a string and I get following fields in confluent cloud.<a href="https://i.stack.imgur.com/kjc0R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kjc0R.png" alt="enter image description here" /></a></p>
  <p>Then, I created a <code>ElasticsearchSink Connector</code> and connected it to elastic search cloud. If I don't create any mapping in elastic search, transfer of data is successful as excepted and the format is something like this.</p>
  <pre><code>&quot;_source&quot; : {
            &quot;booked&quot; : false,
            &quot;phone_number&quot; : &quot;919191919191&quot;,
            &quot;location&quot; : {
              &quot;lon&quot; : 60.23,
              &quot;lat&quot; : 78.233
            }
          }
  </code></pre>
  <p>Now the problem is If I want to run any <code>geo queries</code> it won't allow me and give the following error:</p>
  <pre><code>&quot;root_cause&quot; : [
        {
          &quot;type&quot; : &quot;query_shard_exception&quot;,
          &quot;reason&quot; : &quot;failed to find geo_point field [location]&quot;,
          &quot;index_uuid&quot; : &quot;C8Xxu9QlTMKN4Lk1LjpOmQ&quot;,
          &quot;index&quot; : &quot;locations&quot;
        }
  </code></pre>
  <p>Reason being dynamic mapping does not support geo_field. So now when I try to create a custom mapping for elastic search while creating an index as follow:</p>
  <pre><code>PUT /locations
  {
    &quot;mappings&quot;: {
      &quot;properties&quot;: {
        &quot;phone_number&quot;: {
          &quot;type&quot;: &quot;text&quot;
        },
        &quot;booked&quot;: {
          &quot;type&quot;: &quot;boolean&quot;
        },
        &quot;location&quot;: {
          &quot;type&quot;: &quot;geo_point&quot;
          }
        }
    }
  }
  </code></pre>
  <p>Then confluent connector fails and shows the following error:</p>
  <pre><code>There is a mapping collision in your index: Can't merge a non object mapping with an object mapping.
  </code></pre>
  <p>I have also tried <code>booked</code> as a <code>text</code> field but things does not seem to work. I haven't enforced any schema on Confluent cloud.
  Here is few basic config from confluent cloud.
  <a href="https://i.stack.imgur.com/SqObH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SqObH.png" alt="enter image description here" /></a></p>
  <p>How can I enforce mapping so that I can run <code>geo queries</code> in Elastic Search?</p>
  <p><strong>UPDATE:</strong> This problem persists mainly because of the format of data which is being sent to Kafka</p>
  <pre><code>{
      &quot;phone_number&quot;: &quot;919191919191&quot;,
      &quot;location&quot;: {
              &quot;lat&quot;: 78.233,
              &quot;lon&quot;: 60.23
      },
      &quot;booked&quot;: false,
  }
  
  {
      &quot;phone_number&quot;: &quot;+919191919190&quot;,
      &quot;location&quot;: &quot; 78.233, 60.23&quot;,
      &quot;booked&quot;: false,
  }
  </code></pre>
  <p>Both the format fails to map to above defined mapping in <code>ElasticSearch</code> and <code>connector sink</code> shows following error:</p>
  <pre><code>Received Illegal Argument Exception from Elasticsearch: One of your fields' type does not match the mapped type in Elasticsearch
  </code></pre>