Reputation: 2149
I am getting this error when calling elasticSearch 6.8.8 from a recent ES client exp spring boot 2.5.0
Root mapping definition has unsupported parameters: [_class : {index=false, type=keyword, doc_values=false}]]
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
Here is my unique index document :
@Document(indexName = "my_index")
public class MyDocument implements Serializable {
@Id
private String id;
private String name;
}
ElasticConfig :
@Configuration
@EnableElasticsearchRepositories
public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {
@Value("${elasticsearch.hosts}")
private String hosts;
@Value("${elasticsearch.connectionTimeOut:5000}")
private long connectionTimeOut;
@Value("${elasticsearch.socketTimeOut:5000}")
private long socketTimeOut;
@Override
@Bean
public RestHighLevelClient elasticsearchClient() {
if(hosts == null || hosts.isEmpty()) {
hosts = "localhost:9200";
}
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo(hosts)
.withConnectTimeout(connectionTimeOut)
.withSocketTimeout(socketTimeOut)
.build();
return RestClients.create(clientConfiguration).rest();
}
}
Error :
Caused by: org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=mapper_parsing_exception, reason=Root mapping definition has unsupported parameters: [_class : {index=false, type=keyword, doc_values=false}]]
at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:485)
at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:396)
at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:426)
at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:592)
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:168)
with a new versions of ES i dont have this issue but my production still using 6.8.8
Upvotes: 0
Views: 1215
Reputation: 19431
Elasticsearch 6.8.8 still had mapping types but the client code from the actual version does not set these anymore. And Spring Data Elasticsearch does not add the include_type_name
parameter anymore, this was deprecated since 4.0 and now has been removed.
You either need to upgrade your Elasticsearch cluster to 7.x or downgrade to Spring Data Elasticsearch 4.1.x (that should be Spring Boot 2.4.x). The last version of Spring Data Elasticsearch targetting Elasticsearch 6.8.x was 3.3.
Upvotes: 3