Elasticsearch Rest Client with Spring Data Elasticsearch

后端 未结 3 1016
春和景丽
春和景丽 2020-12-10 01:40

I am in a situation where I am using Spring boot and AWS elasticsearch service. AWS Elasticsearch service which only provides REST interface.

Elasticsearch Rest Clie

3条回答
  •  心在旅途
    2020-12-10 02:28

    Can't comment on Przemek Nowak's answer above. If you don't want to wait for Spring Data ES 2.2.x to use the High Level Rest Client, then Spring Data Jest saves the day.

    As per their documentation, you first disable the default Spring Data ES autoconfiguration:

    @SpringBootApplication(exclude = {
        ElasticsearchAutoConfiguration.class, 
        ElasticsearchDataAutoConfiguration.class
    })
    

    And that's it - the repositories will now use Jest's implementation. And if you'd like to use the ElasticsearchTemplate, make sure you inject ElasticsearchOperations interface instead:

    private final ElasticsearchOperations esTemplate;
    

提交回复
热议问题