본문 바로가기

SearchDeveloper/ElasticSearch

Spring-Data-Elasticsearch VS. Rest-high-level-client

결론: 편하게 개발하고 싶으면 Spring-data-ES / ES가 버전에 민감하면 Rest-high-level-client

Spring-data-ES 도 내부적으로 (ES7부터) ES와 통신할 때 Rest-high-level-client를 사용한다. 

 

<Spring-data-ES>

장점: ORM을 지원해서 데이터를 객체로 ES와 왔다갔다 할 수 있다. 쿼리만들 필요없이 메소드로도 검색할 수 있다. (쿼리도 물론 생성 가능)

단점: 라이브러리가 ES 버전에 민감하다.

 

<Rest-high-level-client>

장점: 쿼리빌더를 생성해야한다.

단점: 버전에 민감하지 않다.

 

참고: 나는 Spring-Data-Elasticsearch를 사용한다. 왜냐면 ES 버전이 쉽게 변하지 않는 환경이고 쿼리도 자유자로 튜닝 가능하고 인덱싱/검색 작업 메소드를 구현하지 않아도 할 수 있고 바로 객체에 매핑되기 때문에 Rest-high-level-client만 사용하는 것에 비해 보일러플레이트코드를 짤 필요가 없다. 

 

References

https://stackoverflow.com/questions/62382457/spring-data-elastic-search-vs-java-high-level-rest-client

 

https://hwangrolee.github.io/Spring-boot%EC%97%90%EC%84%9C-Elasticsearch-%EC%97%B0%EB%8F%99%ED%95%98%EB%A9%B0-%EB%8A%90%EB%82%80%EC%A0%90/

 

https://stackoverflow.com/questions/49172625/spring-data-elastic-search-with-java-high-level-rest-client

If you want to use an ORM on top of Elasticsearch to perform CRUD operations on documents, then Spring Data Elasticsearch is the way to go. 

Beware, though, Spring Data ES lags a bit behind the latest ES releases, so depending on your ES version, it might be more difficult to integrate Spring Data ES (via Spring Boot).

The Java High-Level REST client is getting more traction as Elastic puts more effort into it (since the transport client is doing to disappear). 

The big advantage of this one is that it is the official REST client supported by Elastic and offers a good integration with the request/response DSL, which JEST doesn't.

 

ORM과 Document 단위로 CRUD쓰고 싶으면 Spring Data Elasticsearch사용해라. 하지만 ES 버전에 민감하다.

High-Level REST client는 엘라스틱이 밀어주고 있는 클라이언트다. 가장 큰 장점은 엘라스틱이 요청/응답 DSL을 지원한다는 점이다.