Phil
Phil

Reputation: 7566

Elasticsearch Spring Data with RestHighLevelClient

I don't understand the relationship between the High Level REST CLient (which replaces the Transport Client) and Spring Data Elasticsearch.

There are tutorials (https://www.baeldung.com/spring-data-elasticsearch-tutorial) showing how to make JPA-style queries with auto-implemented methods like getSomethingById(). They utilize this interface:

public interface ElasticsearchRepository<T, ID extends Serializable> extends ElasticsearchCrudRepository<T, ID> {

But ElasticsearchRepository seems to require a @Configuration-Class with an ElasticsearchTemplate-Bean and that requires the TransportClient. As far as I have tried out, there is no way of replacing it with the High/Low Level Java Rest Clients, no?

So if I want to use the newest official Client, there is no JPA-goodness for me?

Upvotes: 8

Views: 5953

Answers (3)

CRISTIAN ROMERO MATESANZ
CRISTIAN ROMERO MATESANZ

Reputation: 1818

Spring Data Moore has been release including this feature (October 8 2019).This is the main description:

Elasticsearch: High Level REST Client support & non Jackson based entity mapping

If yo need more detail You will be able to have a look to this jira issue:

https://jira.spring.io/browse/DATAES-407 for more detail

Upvotes: 0

Abacus
Abacus

Reputation: 19421

spring-data-elasticsearch 3.2.0, now available as M2 contains the code to use the RestClient.

See my answer to this question: What Elasticsearch client does Spring-Data-Elasticsearch use under the hood? for how to set it up

Upvotes: 1

Val
Val

Reputation: 217254

There's an open issue regarding this in the Spring Data ES repo: https://jira.spring.io/browse/DATAES-407

Upvotes: 5

Related Questions