Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Data Elastic Search vs Java High Level REST Client

I'm new to Elastic search. We are building a Spring boot application with Elastic search.

For integrating my Spring boot application either we can use elasticsearch-rest-high-level-client or spring-boot-starter-data-elasticsearch.

Can anyone please elaborate on which option would be overall better and why?

like image 213
Dev Chauhan Avatar asked Jun 15 '20 06:06

Dev Chauhan


People also ask

What is Elasticsearch rest high level client?

High level REST client that wraps an instance of the low level RestClient and allows to build requests and read responses. The RestClient instance is internally built based on the provided RestClientBuilder and it gets closed automatically when closing the RestHighLevelClient instance that wraps it.

What is Java high level REST client?

The Java High-Level REST client works on top of the Java Low-Level REST client. Its main goal is to expose API specific methods, that accept request objects as an argument and return response objects, so that request marshalling and response un-marshalling is handled by the client itself.

Does spring data support Elasticsearch?

Spring Data Elasticsearch provides a simple interface to perform these operations on Elasticsearch as an alternative to using the REST APIs directly.

What is Spring Data Elasticsearch?

Spring Data helps avoid boilerplate code. For example, if we define a repository interface that extends the ElasticsearchRepository interface that Spring Data Elasticsearch provides, CRUD operations for the corresponding document class will become available by default.


1 Answers

spring-boot-starter-data-elasticsearch internally can use the transport(soon to be deprecated in ES 8.X) or rest-high-level-client Please refer elasticsearch client section for more information and how to configure them.

And from the same link :

Spring data Elasticsearch operates upon an Elasticsearch client that is connected to a single Elasticsearch node or a cluster. Although the Elasticsearch Client can be used to work with the cluster, applications using Spring Data Elasticsearch normally use the higher level abstractions of Elasticsearch Operations and Elasticsearch Repositories.

Bottom line is that you can directly use rest-high-level client in your spring boot application but if you want more abstraction then you can use the spring-boot-starter-data-elasticsearch dependency and use its method which provides more abstraction although internally it would use the client offered by Elasticsearch.

like image 86
Amit Avatar answered Oct 21 '22 08:10

Amit