Elasticsearch Rest Client with Spring Data Elasticsearch

Viewed 17784

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 Client is here.

Simply, Is it possible to use REST client with Spring Data Elasticsearch?

In other words, Does Spring Data Elasticsearch works with Elasticsearch Rest client?

Spring Data Elasticsearch is very easy to use and template provides very most functionality that I need. With Elasicsearch Rest client I have to implement all the functionality myself.

3 Answers

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;
Related