elasticsearch – Elastic search high/low rest client vs spring rest template

elasticsearch – Elastic search high/low rest client vs spring rest template

The biggest advantage of using Spring Data Elasticsearch is that you dont have to bother about the things like converting your requests/request bodies/responses from your POJO domain classes to and from the JSON needed by Elasticsearch. You just use the methods defined in the ElasticsearchOperations class which is implemented by the *Template classes.

Or going one abstraction layer up, use the Repository interfaces the all the Spring Data modules provide to store and search/retrieve your data.

Firstly, This is a very broad question. Not sure if it suits the SO guidelines.

But my two cents:

  • High Level Client uses Low Level client which does provide connection pooling
  • High Level client manages the marshalling and unmarshalling of the Elastisearch query body and response, so it might be easier to work using the APIs.

On the other hand, if you are familiar with the Elasticsearch querying by providing the JSON body then you might find it a bit difficult to translate between the JSON body and the Java classes used for creating the query (i.e when you are using Kibana console or other REST API tools)

I generally overcome this by logging the query generated by the Java API so that I can use it with Kibana console or other REST API tools.

Regarding which one is efficient- the library will not matter that much to affect the response times.

If you want to use Spring Reactive features and make use of WebClient, ES Libraries do provide support for Async search.


Please check the answer by Wim Van den Brande below. He has mentioned a very valid point of using Transport Client which has been deprecated over REST API.

So it would be interesting to see how RestTemplate or Spring Data ElasticSearch will update their API to replace TransportClient.

elasticsearch – Elastic search high/low rest client vs spring rest template

One important remark and caveat with regards to the usage of Spring Data Elasticsearch. Currently, Spring Data Elasticsearch doesnt support the communication by the High Level REST Client API. They are using the transport client. Please note, the TransportClient is deprecated as of Elasticsearch 7.0.0 and is expected to be removed in Elasticsearch 8.0!!!

FYI, this statement has been confirmed already by another post: Elasticsearch Rest Client with Spring Data Elasticsearch

Leave a Reply

Your email address will not be published. Required fields are marked *