# Incorrect mapping assigned in Elasticsearch

**URL:** https://discuss.elastic.co/t/incorrect-mapping-assigned-in-elasticsearch/143403
**Category:** Elasticsearch
**Created:** [August 7, 2018, 9:55pm UTC](https://discuss.elastic.co/t/incorrect-mapping-assigned-in-elasticsearch/143403 "2018-08-07T21:55:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cchulo](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@cchulo](https://discuss.elastic.co/u/cchulo)
#### Post date: [August 7, 2018, 9:55pm UTC](https://discuss.elastic.co/t/incorrect-mapping-assigned-in-elasticsearch/143403/1 "2018-08-07T21:55:07Z")

</div>

I am using Elasticsearch, Filebeat, and Logstash 6.3.2

I have a field in the files i'm attempting to index into ES called 'MEAS' and it is of type Double.

Here is an example of one of my JSON files, let's call it File\_A:

```
{
...
   "COND": 295.0
...
}

```

if logstash sends this file first, Elasticsearch will create a mapping for it and assign its type to be 'Long'

so if subsequent JSON files contain "COND" with different value such as this one, lets call it File\_B:

```
{
...
   "COND": 306.145
...
}

```

I receive an error from ES that is "cannot be converted to Long without data loss.

On the flipside: if Elasticsearch were to be fed File\_B first, then the mapping is correct, however, File\_A would be rejected because it "cannot convert long to float".

Before switching to using Logstash/Filebeat, i was sending data directly from a parser written in C#, using [Elasticsearch.NET](http://Elasticsearch.NET) and the low-level client API, and never once did I encounter this issue. That solution was not sustainable, and I was basically reinventing the wheel called "Filebeat".

That said, I'm not sure if my Logstash/Filebeat configurations are to blame, all I need is to index the documents into ES, as the data has already been converted ahead of time, logstash should not need a filter.

here are my configurations:  
filebeat.yml

```
filebeat.inputs:
    - input type: log
      paths:
        - \\AUTOMATIONDEV\DataParser\OutputJSONSnP\*\*.json
        - \\AUTOMATIONDEV\DataParser\OutputJSON\*\*.json
      json.keys_under_root: true
      json.add_error_key: true
      
output.logstash:
    hosts: ["localhost:5051"]

```

logstash.yml

```
input {
	beats {
		host => "127.0.0.1"
		port => "5051"
		codec => "json_lines"
	}
}

output {
	elasticsearch {
		hosts => ["autoelk-01:9200", "autoelk-02:9200", "autoelk-03:9200"]
		index => "%{doc_index}"
		document_type => "%{doc_type}"
		document_id => "%{doc_id}"
	}
}

```

Any help would be gladly appreciated.

Would creating a mapping resolve this issue? I have tried turning off coerce when creating index.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 4, 2018, 9:57pm UTC](https://discuss.elastic.co/t/incorrect-mapping-assigned-in-elasticsearch/143403/2 "2018-09-04T21:57:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
