Reputation: 433
I created a new index a1.
curl -XGET "http://localhost:41349/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open a1 ba3S75mbSWyNdP2XYip8VA 5 1 0 0 810b 810b
When I try to index the document to a1 I get error.
curl -XPOST "http://localhost:41349/a1/_doc" -H "Content-Type:application/json" -d '{"dummy": "data"}'
{"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_doc]"}],"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_doc]"},"status":400}
I tried with PUT. This also failed.
curl -XPUT --header 'Content-Type: application/json' http://localhost:41349/_doc/1 -d '{ "school" : "Harvard" }'
No handler found for uri [/_doc/1] and method [PUT]
Upvotes: 1
Views: 4167
Reputation: 16172
It seems that you are using Elasticsearch version below 7.x. The error clearly states that mapping type name cannot start with _
Document mapping type name can't start with '_'
You need to change your mapping type name (change from _doc
to doc
). Modify your curl request as
curl -XPOST "http://localhost:41349/a1/doc" -H "Content-Type:application/json" -d '{"dummy": "data"}'
Upvotes: 3