【问题标题】:Spring Data ElasticSearch (Specifying types in search requests is deprecated)Spring Data ElasticSearch(不推荐在搜索请求中指定类型)
【发布时间】:2021-03-03 09:53:56
【问题描述】:

这里是弹性搜索初学者。

通过扩展ElasticsearchRepositoryProviderRepository 执行.findAll() 操作时,我看到以下警告。

2020-11-19_17:31:09.218 WARN  org.elasticsearch.client.RestClient - [::] request [POST http://mysearch:9200/provider_search/provider/_search?rest_total_hits_as_int=true&typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&search_type=query_then_fetch&batched_reduce_size=512] returned 1 warnings: [299 Elasticsearch-7.6.2-ef48eb35cf30adf4db14086e8aabd07ef6fb113f "[types removal] Specifying types in search requests is deprecated."]

我不希望 URL 中的 /provider/ 部分。如果我粘贴没有 /provider/ 部分的 URL,我可以获得所需的响应。 /provider/ 部分导致请求返回 0 个结果。但是,我不确定 /provider/ 部分附加到 URL 的哪个位置。

这是我的存储库

public interface ProviderRepository extends ElasticsearchRepository<Provider, Long> {
}

这是实体/文档

@Document(indexName = "provider_search")
public class Provider {

     private Long id;

     private String providerName;

    ...
}

还有,这是我的配置

@Configuration
@EnableElasticsearchRepositories(
    basePackages = { "com.commons.repositories.elastic" })
public class ElasticDataSourceConfig {

    @Bean
    public RestHighLevelClient client() {
        ClientConfiguration clientConfiguration = ClientConfiguration.builder()
            .connectedTo("mysearch:9200")
            .build();

        return RestClients.create(clientConfiguration).rest();
    }

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() {
        return new ElasticsearchRestTemplate(client());
    }
}

如果我需要提供更多信息,请告诉我。

Tl;博士 需要帮助从上述 URL 中删除 /provider/ 部分。

【问题讨论】:

  • 您使用哪个版本的 Spring Data Elasticsearch?您的 Elasticsearch 集群是哪个版本的?
  • SpringData 弹性搜索是 4.1.1。集群版本是7.6.2,我也有elasticsearch:版本7.10.0

标签: java elasticsearch spring-data-elasticsearch


【解决方案1】:

我必须将 Spring Boot 版本从 2.2.* 更新到 2.3.* 才能使其正常工作。出于某种原因,spring-boot-starter-data 的嵌入式传递依赖项与我的直接弹性搜索依赖项相混淆。即使我安装了 4.0.* spring-data-elasticsearch,spring-data-elasticsearch 中的传递依赖项也在 6.* 版本中。有一次,我更新了 Spring Boot,spring-data-elasticsearch(版本 4.0.)的所有传递依赖都从 6. 更改为 7.*.

【讨论】:

    猜你喜欢
    • 2019-10-18
    • 2020-05-09
    • 2021-04-02
    • 2020-06-18
    • 2022-01-06
    • 2020-09-10
    • 1970-01-01
    • 2016-09-07
    • 1970-01-01
    相关资源
    最近更新 更多