Elastic output plugin: result _type in Elastic is always "doc"

I am using the latest (6.0) ElasticStack for clear setup (no migrations)

I have the following type mapping:

PUT my_index
{
  "mappings": {
    "my_type":
    {
      "dynamic": "strict",
      "properties":
      {
        "CampaignId":         { "type": "integer"},
        "DepartmentId":       { "type": "integer"},
        "CompanyId":          { "type": "integer"},
        "Budget":             { "type": "double"},
        "StartDate":          { "type": "date"},
        "EndDate":            { "type": "date"}
      }
    }
  }
}

Adding a new document works fine and creates a document with the _type=my_type

 POST my_index/my_type
 {
      "CampaignId" : 12,
      "DepartmentId" : 10,
      "CompanyId": 100,
      "Budget": 123.123
  }

But when I use the Logstash it creates documents with _type=doc and fail to add them into the index with this error:.

Rejecting mapping update to [my_index] as the final mapping would have more than 1 type: [my_type, doc]

I can fix it by adding the document_type => "my_type", but it's obsolete in version 6, so suspect it should work without it or there is another way to specify the _type.

Logstash conf:

input { jdbc { ... } }
filter { }
output 
{
  elasticsearch 
  {
    hosts => "localhost:9200"
    index => "my_index"
    action => update
	document_id => "%{FieldId}"
	doc_as_upsert => true
  }
}

In V6 an index can only have a single type. If you want that type to be "my_type" then setting it with document_type in the logstash output is the right thing to do. Yes, it is deprecated now, but that's what it is for. Or else add the documents as type doc to start with.

1 Like

Yep, i want the my-type will be the single type in the my_index.
It seems to me very strange, that it's "the right thing to do".
Usually if something is obsolete, there is a replacement and the old way is not intended to be used in a new code. Suspect there is some else explanation.
But thanks for the answer.

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