2022-12-12-TIL
2022-12-12-TIL
Today I Learned
검색 엔진을 고를 때 자주 나오는 Elasticsearch와 OpenSearch의 관계, Elasticsearch를 공부할 자료, 그리고 Spring Boot와 MyBatis 조합에서 테스트를 작성하는 방법을 정리했다.
Elasticsearch vs OpenSearch
두 제품은 원래 같은 코드에서 출발했다. AWS 블로그에 따르면 Elastic NV는 2021년 1월 21일 라이선스 전략 변경을 발표했고, Elasticsearch와 Kibana 7.10.2 이후 버전은 더 이상 Apache License 2.0으로 배포하지 않기로 했다. Elastic의 라이선스 FAQ는 7.11 릴리스부터 소스 코드를 SSPL과 Elastic License의 이중 라이선스로 전환했다고 설명한다. 두 라이선스 모두 OSI 승인 오픈소스 라이선스가 아니며, 특히 관리형 서비스로 제공하는 사업자에게 제약이 생긴다.
AWS는 마지막 Apache 2.0 버전인 Elasticsearch 7.10.2와 Kibana 7.10.2를 포크해 OpenSearch와 OpenSearch Dashboards를 만들었고, 기존 Amazon Elasticsearch Service의 이름을 Amazon OpenSearch Service로 바꿨다. 둘 다 Apache Lucene 위에서 동작하고 OpenSearch 1.0은 Elasticsearch 7.10 API와 호환되지만, 포크 이후 기능은 각자 발전하고 있다. Elastic FAQ에 따르면 2024년에는 AGPLv3가 소스 코드 라이선스 선택지로 추가되었다.
선택 기준은 대략 이렇다.
- 라이선스: 사내에서 직접 쓰거나 SaaS 백엔드로 쓰는 경우 Elastic FAQ는 영향이 없다고 설명한다. Elasticsearch 자체를 서비스로 재판매하는 경우에만 문제가 된다.
- 기능과 생태계: 7.11 이후 추가된 Elastic의 기능이 필요하면 Elasticsearch, AWS 관리형 서비스와의 통합이 중요하면 OpenSearch 쪽이 편하다.
클라이언트 호환성: 포크 이후 버전이 갈라졌으므로 클라이언트 라이브러리를 어느 쪽에 맞출지 미리 정해야 한다.
- https://aws.amazon.com/ko/what-is/opensearch/
- https://aws.amazon.com/ko/blogs/aws/amazon-elasticsearch-service-is-now-amazon-opensearch-service-and-supports-opensearch-10/
- https://aws.amazon.com/ko/blogs/korea/keeping-open-source-open-open-distro-for-elasticsearch/
- https://couplewith.tistory.com/entry/%EB%8B%AC%EB%9D%BC%EC%A7%80%EB%8A%94-%EC%98%A4%ED%94%88-%EC%86%8C%EC%8A%A4-Elasticsearch%EC%9D%98-%EB%9D%BC%EC%9D%B4%EC%84%A0%EC%8A%A4-%EC%A0%84%EB%9E%B5
- https://www.elastic.co/kr/about/free-and-open
- https://www.elastic.co/kr/amazon-opensearch-service
- https://www.elastic.co/kr/pricing/faq/licensing
- https://m.blog.naver.com/PostView.nhn?isHttpsRedirect=true&blogId=occidere&logNo=222209247067&proxyReferer=
- http://kimjmin.net/2020/06/2020-06-elastic-devrel/
- https://www.oss.kr/oss_license_qna/show/936b1eb5-e62f-4e25-8a6d-dc705ef66199
- https://logit.io/blog/post/aws-elasticsearch-vs-opensearch-vs-open-distro/
- https://pureinsights.com/blog/2021/elasticsearch-vs-opensearch-user-point-of-view-part-1-of-3/
- https://dattell.com/data-architecture-blog/opensearch-vs-elasticsearch/
- https://blog.opsnow.com/elasticsearch%EB%A5%BC-%EB%91%98%EB%9F%AC%EC%8B%BC-aws%EC%99%80-elastic%EC%9D%98-%EB%8C%80%EB%A6%BD/
- https://www.youtube.com/watch?v=F1oKcMefb0A
Elasticsearch
Elasticsearch는 Lucene 기반의 분산 검색·분석 엔진이다. 문서를 JSON으로 저장하고, 텍스트 필드는 분석기(analyzer)로 토큰화해 역색인(inverted index)을 만든다. 역색인은 “단어 → 그 단어가 들어 있는 문서 목록” 구조라서 전문 검색이 빠르다. 인덱스는 여러 샤드로 나뉘어 노드에 분산되고, 각 샤드에 레플리카를 두어 장애와 읽기 부하에 대비한다. 모든 조작은 REST API로 한다.
Logstash, Beats, Kibana와 묶어 Elastic Stack(예전 이름 ELK)으로 쓰는 경우가 많고, 검색 외에 로그 수집과 모니터링 용도로도 널리 쓰인다. 처음 공부할 때는 공식 레퍼런스와 김종민 님의 한국어 가이드북(esbook)으로 기본 개념을 잡고, 나머지 책 추천 목록은 필요한 주제가 생기면 찾아보는 정도로 두었다.
- https://www.samsungsds.com/kr/insights/elasticsearch.html
- https://esbook.kimjmin.net/01-overview/1.1-elastic-stack
- https://velog.io/@ayoung0073/Elasticsearch-%EC%9E%85%EB%AC%B8-%EA%B3%B5%EB%B6%80
- https://www.elastic.co/guide/en/elasticsearch/reference/current/starting-elasticsearch.html
- https://github.com/moabdi/Elasticsearch-Books
- https://www.quora.com/What-are-the-best-resources-to-master-Elasticsearch
- https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
- https://sematext.com/resources/publications/
- https://github.com/elastic/elasticsearch-definitive-guide
- https://github.com/moabdi/Elasticsearch-Books
- https://www.goodreads.com/shelf/show/elasticsearch
- https://opensourceconnections.com/blog/2016/09/09/better-recsys-elasticsearch/
- https://discuss.elastic.co/t/elastic-search-book-recommendation-2020/219007
- https://www.tangolearn.com/best-elasticsearch-books/
- https://www.reddit.com/r/elasticsearch/comments/g2ec05/recent_books_on_elasticsearch/
- https://www.quora.com/What-is-the-best-ElasticSearch-book
- https://elasticsearchbook.com/
- https://www.devglan.com/programming/elasticsearch-books
- https://www.oreilly.com/library/view/elasticsearch-the-definitive/9781449358532/
- https://whatpixel.com/best-elasticsearch-books/
- https://www.elastic.co/guide/en/elasticsearch/guide/index.html
- https://esbook.kimjmin.net/
- https://computingforgeeks.com/best-books-to-learn-elasticsearch-and-kibana/
Spring Boot + MyBatis 테스트 코드
MyBatis 매퍼를 테스트하는 방법은 범위에 따라 나뉜다.
- 매퍼 단위 테스트:
mybatis-spring-boot-starter-test의@MybatisTest를 쓰면SqlSessionFactory,SqlSessionTemplate, 매퍼 인터페이스와 내장 DB만 구성하고 일반@Component빈은 올리지 않는다. 문서에 따르면 이 테스트는 기본적으로 트랜잭션 안에서 실행되고 각 테스트가 끝나면 롤백된다. - 서비스 테스트: 매퍼를 Mockito로 대체해 비즈니스 로직만 검증하거나,
@SpringBootTest로 전체 컨텍스트를 띄워 실제 DB까지 통합해서 검증한다. 트랜잭션 롤백: Spring TestContext 프레임워크에서 테스트 메서드에
@Transactional을 붙이면 기본 동작은 테스트 후 롤백이다. 커밋 결과를 확인해야 하면@Commit이나@Rollback(false)를 쓴다.- https://powersmile-it.tistory.com/31
- https://deveun.tistory.com/entry/SpringBoot-Mybatis%EB%A5%BC-%EC%82%AC%EC%9A%A9%ED%95%9C-Service-%ED%85%8C%EC%8A%A4%ED%8A%B8-%EC%BD%94%EB%93%9C-%EC%9E%91%EC%84%B1%ED%95%98%EA%B8%B0
- https://kjh95.tistory.com/343
- https://docs.spring.io/spring-framework/docs/current/reference/html/testing.html#testcontext-tx-enabling-transactions
- https://cosmos8749.tistory.com/41?category=1227034
- http://mybatis.org/spring-boot-starter/mybatis-spring-boot-test-autoconfigure/
댓글
아직 댓글이 없습니다