0

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?

1
  • Important Multiple mapping types are not supported in indices created in 6.0 Commented Dec 9, 2018 at 13:55

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

So, what I need to do?
I would suggest looking at your mapping and adjusting so there is only one type in a single index
0

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

2 Comments

Got this error: {"error":"Incorrect HTTP method for uri [/cars/] and method [POST], allowed: [PUT, HEAD, GET, DELETE]","status":405}
@bugnet17 try PUT and note that only one mapping type is supported in ES 6.x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.