# Mapping to type long fails when dynamic template is used

**URL:** https://discuss.elastic.co/t/mapping-to-type-long-fails-when-dynamic-template-is-used/54694
**Category:** Logstash
**Created:** [July 5, 2016, 8:23am UTC](https://discuss.elastic.co/t/mapping-to-type-long-fails-when-dynamic-template-is-used/54694 "2016-07-05T08:23:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)
#### Post date: [July 5, 2016, 8:23am UTC](https://discuss.elastic.co/t/mapping-to-type-long-fails-when-dynamic-template-is-used/54694/1 "2016-07-05T08:23:03Z")

</div>

Hello.

I would like to ask question about creating a index in elasticsearch.

**My Question**  
Why is elasicsearch rejecting the indexing for field which has type : long?

**What am I trying to do?**  
I am indexing the linux syslog into elasticsearch using grok in logstash.  
Below is my grok definition.

```
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => ["received_at", "%{@timestamp}"]
      add_field => ["received_from", "%{host}"]
    }
    syslog_pri { }
    date {
      match => ["syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]
    }
  }

```

**What is happening?**  
Elasticsearch is rejecting the indexing as below.

```
[2016-07-05 17:12:03,217][DEBUG][action.admin.indices.create] [node-1] [mksyslog-2016.07.05] failed to create
MapperParsingException[Failed to parse mapping [syslog_severity_code]: Root mapping definition has unsupported parameters: [type : long]]; nested: MapperParsingException[Root mapping definition has unsupported parameters: [type : long]];

```

I use the dynamic template to auto create the index.  
Below is my whole PUT query when I created the template.  
syslog\_severity\_code is defined as type.

```
PUT /_template/syslog_template
{
    "template": "*syslog*",
    "settings": {
      "index": {
        "number_of_shards": "5",
        "number_of_replicas": "1"
      }
    },
    "mappings": {
      "tags": {
        "index": "not_analyzed",
        "type": "string"
      },
      "syslog_severity_code": {
        "type": "long"
      },
      "syslog_facility_code": {
        "type": "long"
      },
      "host": {
        "index": "not_analyzed",
        "type": "string"
      },
      "syslog_message": {
        "index": "not_analyzed",
        "type": "string"
      },
      "syslog_program": {
        "index": "not_analyzed",
        "type": "string"
      },
      "syslog_facility": {
        "index": "not_analyzed",
        "type": "string"
      },
      "syslog_hostname": {
        "index": "not_analyzed",
        "type": "string"
      },
      "@version": {
        "index": "not_analyzed",
        "type": "string"
      },
      "syslog_pid": {
        "index": "not_analyzed",
        "type": "string"
      },
      "message": {
        "type": "string"
      },
      "path": {
        "index": "not_analyzed",
        "type": "string"
      },
      "syslog_severity": {
        "index": "not_analyzed",
        "type": "string"
      },
      "syslog_timestamp": {
        "index": "not_analyzed",
        "type": "string"
      },
      "@timestamp": {
        "format": "strict_date_optional_time||epoch_millis",
        "type": "date"
      },
      "type": {
        "index": "not_analyzed",
        "type": "string"
      },
      "received_from": {
        "index": "not_analyzed",
        "type": "string"
      },
      "received_at": {
        "format": "strict_date_optional_time||epoch_millis",
        "type": "date"
      }
    }
  } 

```

My platform environment is below.

OS : RHEL 7.2 64bit  
Elasticsearch : 2.3.3  
Logstash : 2.3.3

Any help is appreciated!

---

<div class="post-metadata">

### Author: ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)
#### Post date: [July 5, 2016, 8:51am UTC](https://discuss.elastic.co/t/mapping-to-type-long-fails-when-dynamic-template-is-used/54694/2 "2016-07-05T08:51:40Z")

</div>

I have deleted the template and changed some order of the index template PUT query.  
I now have different error.

```
[2016-07-05 17:48:28,892][DEBUG][action.admin.indices.create] [node-1] [mksyslog-2016.07.05] failed to create
MapperParsingException[Failed to parse mapping [syslog_pid]: Root mapping definition has unsupported parameters: [index : not_analyzed] [type : string]]; nested: MapperParsingException[Root mapping definition has unsupported parameters: [index : not_analyzed] [type : string]];
        at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:332)
        at org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:45)
        at org.elasticsearch.cluster.service.InternalClusterService.runTasksForExecutor(InternalClusterService.java:468)
        at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:772)
        at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:231)
        at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:194)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: MapperParsingException[Root mapping definition has unsupported parameters: [index : not_analyzed] [type : string]]
        at org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:171)
        at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:159)
        at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:99)
        at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:508)
        at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:288)
        at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:329)
        ... 8 more
```

---

<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 6, 2017, 4:49am UTC](https://discuss.elastic.co/t/mapping-to-type-long-fails-when-dynamic-template-is-used/54694/3 "2017-07-06T04:49:33Z")

</div>


