# Inconsistent field mapping -- sometimes string, sometimes long

**URL:** <https://discuss.elastic.co/t/inconsistent-field-mapping-sometimes-string-sometimes-long/39036>\
**Category:** Elasticsearch\
**Created:** [January 12, 2016, 8:54pm UTC](https://discuss.elastic.co/t/inconsistent-field-mapping-sometimes-string-sometimes-long/39036 "2016-01-12T20:54:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![khadrin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khadrin/32/7106_2.png) [@khadrin](https://discuss.elastic.co/u/khadrin)\
**Post date:** [January 12, 2016, 8:54pm UTC](https://discuss.elastic.co/t/inconsistent-field-mapping-sometimes-string-sometimes-long/39036/1 "2016-01-12T20:54:55Z")

</div>

The following api request sometimes returns that **date** is a string, other times it's a long.  
It looks to be about 50/50 but random whether it returns string or long. I expected it would always return the same. What am I missing?

We are on Elasticsearch 1.1.2 if that matters.

Thanks,  
Stephen

```
$ for ((i=0;i<2;++i)) do curl -s 'http://localhost:9200/logstash-2016.01.11/_mapping/logs/field/date?pretty=true'; done                                                                                                                                               
{
  "logstash-2016.01.11" : {
    "mappings" : {
      "logs" : {
        "date" : {
          "full_name" : "date", "mapping" : {"date":{"type":"string","norms":{"enabled":false},"fields":{"raw":{"type":"string","index":"not_analyzed","ignore_above":256}}}}
        }
      }
    }
  }
}
{
  "logstash-2016.01.11" : {
    "mappings" : {
      "logs" : {
        "date" : {
          "full_name" : "date", "mapping" : {"date":{"type":"long"}}
        }
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 14, 2016, 7:13am UTC](https://discuss.elastic.co/t/inconsistent-field-mapping-sometimes-string-sometimes-long/39036/2 "2016-01-14T07:13:45Z")

</div>

Ouch, do you have more than one node in your cluster? It could be that the cluster state is out of sync between them.

> [@khadrin](#):
>
> We are on Elasticsearch 1.1.2 if that matters.

Time to upgrade!

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [January 14, 2016, 9:30am UTC](https://discuss.elastic.co/t/inconsistent-field-mapping-sometimes-string-sometimes-long/39036/3 "2016-01-14T09:30:55Z")

</div>

I think you might be hitting the issue described in [this post](https://discuss.elastic.co/t/sum-aggregation-returning-very-small-unrelated-values/26890/4?u=colings86) . This is a bug that was fixed in 2.0 so you will need to upgrade to avoid hitting it again or explicitly map the fields in your index and not rely on the dynamic mapping

---

<div class="post-metadata">

**Author:** ![khadrin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khadrin/32/7106_2.png) [@khadrin](https://discuss.elastic.co/u/khadrin)\
**Post date:** [January 14, 2016, 9:09pm UTC](https://discuss.elastic.co/t/inconsistent-field-mapping-sometimes-string-sometimes-long/39036/4 "2016-01-14T21:09:01Z")

</div>

Thanks guys. Does look like it might be the issue mentioned that was fixed in 2.0. We are working on upgrading, so hopefully that fixes it!

---

<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:** [July 5, 2017, 11:24pm UTC](https://discuss.elastic.co/t/inconsistent-field-mapping-sometimes-string-sometimes-long/39036/5 "2017-07-05T23:24:21Z")

</div>


