# Logstash unable to index due to multiple doc types in mapping

**URL:** <https://discuss.elastic.co/t/logstash-unable-to-index-due-to-multiple-doc-types-in-mapping/168944>\
**Category:** Logstash\
**Created:** [February 19, 2019, 6:52am UTC](https://discuss.elastic.co/t/logstash-unable-to-index-due-to-multiple-doc-types-in-mapping/168944 "2019-02-19T06:52:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbking](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bbking/32/77563_2.png) [@bbking](https://discuss.elastic.co/u/bbking)\
**Post date:** [February 19, 2019, 6:52am UTC](https://discuss.elastic.co/t/logstash-unable-to-index-due-to-multiple-doc-types-in-mapping/168944/1 "2019-02-19T06:52:32Z")

</div>

Hi, I manually put an index template in Elasticsearch with doc\_type `doc`. But when Logstash tries to index an event using this template. it shows `failed to index due to multiple doc types`. I think the template I defined is the same as the doc type in the event, which is `doc`. Can anyone explain why it failed to index?

Another question:  
If I update the index pattern, will Logstash use the new index pattern or still cache the old index pattern?

```auto
[2019-02-18T22:37:05,637][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"log-2019", :_type=>"doc", :_routing=>nil}, #<LogStash::Event:0xdc6d769>], :response=>{"index"=>{"_index"=>"log-2019", "_type"=>"doc", "_id"=>"4yZ4BGkBCjBT-EkD5FW0", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"Rejecting mapping update to [log-2019] as the final mapping would have more than 1 type: [_doc, doc]"}}}}

```

Template defined use Template API:

```auto
PUT _template/log-success
{
  "index_patterns": ["log-*"],
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas" : 0,
    "index.refresh_interval": "5s"
  },
  "mappings": {
    "doc": {
      "dynamic": "strict",
      "properties": {
        "@timestamp" : {"type" : "date"},
        "@version" : {"type" : "keyword"},
        "source" : {"type" : "keyword"}
      }
    }
  }
}

```

Logstash pipeline.conf:

```auto
input {
    beats {
        port => "5044"
    }
}

filter {
  ruby {
    path => "./parse.rb"
  }

  date {
    match => ["time", "EEE MMM dd HH:mm:ss z yyyy"]
    remove_field => ["time"]
  }
}

output {
  stdout { codec => rubydebug }
  if [parsingError] {
    elasticsearch {
      manage_template => false
      template_name => "log-failure"
      hosts => ["localhost:9200"]
      index => "failure-log-%{+yyyy}"
    }
  }
  else {
    elasticsearch {
      manage_template => false
      template_name => "log-success"
      hosts => ["localhost:9200"]
      index => "log-%{+yyyy}"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 24, 2019, 8:18pm UTC](https://discuss.elastic.co/t/logstash-unable-to-index-due-to-multiple-doc-types-in-mapping/168944/2 "2019-02-24T20:18:44Z")

</div>

Th default document type used by Logstash (and the rest of the stack) is `_doc` and not `doc`. If you change your index template accordingly it should work.

---

<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:** [March 24, 2019, 8:18pm UTC](https://discuss.elastic.co/t/logstash-unable-to-index-due-to-multiple-doc-types-in-mapping/168944/3 "2019-03-24T20:18:49Z")

</div>

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