简体   繁体   English

使用最近的客户端 RestHighLevelClient 7.12.1 调用旧版本 ElasticSearch exp:6.8.8

[英]Calling old version ElasticSearch exp :6.8.8 with a recent client RestHighLevelClient 7.12.1

I am getting this error when calling elasticSearch 6.8.8 from a recent ES client exp spring boot 2.5.0从最近的 ES 客户端 exp spring boot 2.5.0 调用 elasticSearch 6.8.8 时出现此错误

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使用新版本的 ES 我没有这个问题,但我的产品仍在使用 6.8.8

Elasticsearch 6.8.8 still had mapping types but the client code from the actual version does not set these anymore. Elasticsearch 6.8.8 仍然有映射类型,但实际版本的客户端代码不再设置这些。 And Spring Data Elasticsearch does not add the include_type_name parameter anymore, this was deprecated since 4.0 and now has been removed.并且 Spring 数据 Elasticsearch 不再添加include_type_name参数,自 4.0 以来已弃用,现在已被删除。

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). 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.针对 Elasticsearch 6.8.x 的 Spring 数据 Elasticsearch 的最新版本是 3.3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM