0
votes

I'm trying to insert data directly to elastic search into a specific index called "cars" via the curl command but it is constantly encountering errors.

curl -XPOST http://elk.local:9200/cars/my_doc -H "Content-Type: application/json" -d @test.json

JSON example:

{
"name":"John",
"age":30,
"cars":[ "Ford", "BMW", "Fiat" ]
}

Error:

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [cars] as the final mapping would have more than 1 type: [my_doc, log]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [cars] as the final mapping would have more than 1 type: [my_doc, log]"},"status":400}

any ideas how to do it correctly?

2
Important Multiple mapping types are not supported in indices created in 6.0Always Sunny

2 Answers

1
votes

I would suggest looking at your mapping and adjusting so there is only one type in a single index

From the ES documentation:

Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Mapping types will be completely removed in Elasticsearch 7.0.0.

In your case it seems your cars index have 2 types one is my_doc and another is log that's why you're getting this error

Rejecting mapping update to [cars] as the final mapping would have more than 1 type: [my_doc, log]

See: https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html

0
votes

From the request I see that you are using ‘GET’ to insert data which is not correct. Use POST instead.