# Mixing up field types: on field \_ttl on elasticsearch 2.3

**URL:** <https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610>\
**Category:** Elasticsearch\
**Created:** [July 15, 2016, 11:08am UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610 "2016-07-15T11:08:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajind\_Ruparathna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajind_ruparathna/32/10545_2.png) [@Rajind\_Ruparathna](https://discuss.elastic.co/u/Rajind_Ruparathna)\
**Post date:** [July 15, 2016, 11:08am UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/1 "2016-07-15T11:08:53Z")

</div>

I am using following in my mapping.  
\_ttl: {  
"enabled": true,  
"default": "15m"  
}

I get failed to execute bulk item (index) index {[ultraesb][msg\_statistics][AVXuOaBoYt4h9lsSojgC], source[{"totalMessageCount":7,"recordTime":"2016-07-15T16:33:12+0530","\_ttl":"15m"}]}

Caused by: java.lang.IllegalStateException: Mixing up field types: class org.elasticsearch.index.mapper.core.LongFieldMapper$LongFieldType != class org.elasticsearch.index.mapper.internal.TTLFieldMapper$TTLFieldType on field \_ttl

All i could find is [this github discussion](https://github.com/elastic/elasticsearch/issues/14566) but doesn't tell how to solve the issue.

Any help is highly appreciated.

---

<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:** [July 17, 2016, 7:42am UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/2 "2016-07-17T07:42:47Z")

</div>

What does the rest of the mapping look like?

ALlso, `ttl` is deprecated so you shouldn't use it, it'll be removed in v5.

---

<div class="post-metadata">

**Author:** ![Rajind\_Ruparathna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajind_ruparathna/32/10545_2.png) [@Rajind\_Ruparathna](https://discuss.elastic.co/u/Rajind_Ruparathna)\
**Post date:** [July 18, 2016, 8:43am UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/3 "2016-07-18T08:43:09Z")

</div>

```
{
  "ultraesb" : {
    "mappings" : {
      "msg_statistics" : {
        "_timestamp" : {
          "enabled" : true
        },
        "_ttl" : {
          "enabled" : true,
          "default" : 900000
        },
        "dynamic_templates" : [ {
          "index_nonanalyzed" : {
            "mapping" : {
              "index" : "not_analyzed"
            },
            "match" : "*"
          }
        } ],
        "properties" : {
          "customFields" : {
            "type" : "nested"
          },
          "recordTime" : {
            "type" : "date",
            "format" : "yyyy-MM-dd'T'HH:mm:ssZ"
          }
        }
      }
    }
  }
}

```

Thank you for your reply. I know that ttl is deprecated but I would like to get ttl to work in 2.3 for now rather that upgrading to use 5.x

---

<div class="post-metadata">

**Author:** ![Rajind\_Ruparathna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajind_ruparathna/32/10545_2.png) [@Rajind\_Ruparathna](https://discuss.elastic.co/u/Rajind_Ruparathna)\
**Post date:** [July 18, 2016, 8:44am UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/4 "2016-07-18T08:44:05Z")

</div>

Full stacktrace

```
MapperParsingException[failed to parse]; nested: IllegalStateException[Mixing up field types: class org.elasticsearch.index.mapper.core.LongFieldMapper$LongFieldType != class org.elasticsearch.index.mapper.internal.TTLFieldMapper$TTLFieldType on field _ttl];
    at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:154)
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:309)
    at org.elasticsearch.index.shard.IndexShard.prepareCreate(IndexShard.java:529)
    at org.elasticsearch.index.shard.IndexShard.prepareCreateOnPrimary(IndexShard.java:506)
    at org.elasticsearch.action.index.TransportIndexAction.prepareIndexOperationOnPrimary(TransportIndexAction.java:215)
    at org.elasticsearch.action.index.TransportIndexAction.executeIndexRequestOnPrimary(TransportIndexAction.java:224)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.shardIndexOperation(TransportShardBulkAction.java:326)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:119)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:68)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase.doRun(TransportReplicationAction.java:639)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:279)
    at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryOperationTransportHandler.messageReceived(TransportReplicationAction.java:271)
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
    at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Mixing up field types: class org.elasticsearch.index.mapper.core.LongFieldMapper$LongFieldType != class org.elasticsearch.index.mapper.internal.TTLFieldMapper$TTLFieldType on field _ttl
    at org.elasticsearch.index.mapper.FieldMapper.updateFieldType(FieldMapper.java:397)
    at org.elasticsearch.index.mapper.FieldMapper.updateFieldType(FieldMapper.java:53)
    at org.elasticsearch.index.mapper.DocumentParser.parseDynamicValue(DocumentParser.java:622)
    at org.elasticsearch.index.mapper.DocumentParser.parseValue(DocumentParser.java:442)
    at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:262)
    at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:122)
    ... 18 more
```

---

<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:** [July 18, 2016, 10:28am UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/5 "2016-07-18T10:28:22Z")

</div>

> [@Rajind\_Ruparathna](#):
>
> Mixing up field types

Is that the entire mapping for the index?

---

<div class="post-metadata">

**Author:** ![Rajind\_Ruparathna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajind_ruparathna/32/10545_2.png) [@Rajind\_Ruparathna](https://discuss.elastic.co/u/Rajind_Ruparathna)\
**Post date:** [July 18, 2016, 10:29am UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/6 "2016-07-18T10:29:28Z")

</div>

yes. Actually i tried without setting any default ttl value as you can see in the mapping. Still i get the same error though. I tried give ttl as a long value(900000L) as a string (like "900000" and "15m") too. Still no luck.

---

<div class="post-metadata">

**Author:** ![Jeff\_Baker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeff_baker/32/14524_2.png) [@Jeff\_Baker](https://discuss.elastic.co/u/Jeff_Baker)\
**Post date:** [January 12, 2017, 10:36pm UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/7 "2017-01-12T22:36:24Z")

</div>

I am facing the same issue in 2.3; the only way I have successfully used TTL is by setting a default TTL, but any attempt to create a record with a specific TTL in the JSON, both with and without extensions like "ms", results in the "Mixing up field types: class org.elasticsearch.index.mapper.core.LongFieldMapper$LongFieldType != class org.elasticsearch.index.mapper.internal.TTLFieldMapper$TTLFieldType on field \_ttl" error.

---

<div class="post-metadata">

**Author:** ![Rajind\_Ruparathna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajind_ruparathna/32/10545_2.png) [@Rajind\_Ruparathna](https://discuss.elastic.co/u/Rajind_Ruparathna)\
**Post date:** [January 13, 2017, 12:16am UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/8 "2017-01-13T00:16:46Z")

</div>

I also ended up using the default \_ttl. Now I have moved to 5.1.1 which does not have the ttl support but has the index roll over support. [https://www.elastic.co/blog/managing-time-based-indices-efficiently](https://www.elastic.co/blog/managing-time-based-indices-efficiently)

You might want to also consider these product end dates for selecting a version. [https://www.elastic.co/support/eol](https://www.elastic.co/support/eol)

If you want to stick to 2.x, perhaps you could try a slightly newer version like 2.4.1. [https://www.elastic.co/downloads/past-releases/elasticsearch-2-4-1](https://www.elastic.co/downloads/past-releases/elasticsearch-2-4-1)

---

<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, 10:04pm UTC](https://discuss.elastic.co/t/mixing-up-field-types-on-field--ttl-on-elasticsearch-2-3/55610/9 "2017-07-05T22:04:14Z")

</div>


