问题描述:

Suppressed: org.elasticsearch.client.ResponseException: method [PUT], host [​​http://localhost:9200​​​​], URI [/search/​doc/4?timeout=1m], status line [HTTP/1.1 400 Bad Request]
{"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}

at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:283)

at org.elasticsearch.client.RestClient.performRequest(RestClient.java:261)

at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235)

at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1611)

... 5 more

问题原因:

旧版本ES必须指定type,新版java api默认type为_doc

解决方案:


  1. 指定type

IndexRequest indexRequest = new IndexRequest(INDEX, TYPE);

  1. 升级es至7.x以后版本


时间会记录下一切。