오픈소스 검색엔진인 Elasticsearch 어떻게 저장하고 조회하는지 검색엔진의 개념에 대해서 간단히 살펴보고, Node.js 로 구현된 아주 간단한 예제를 소개합니다.
- 검색엔진과 Elasticsearch 소개
- Elasticsearch에서의 색인
- Elasticsearch에서의 조회
- Node.js 로 구현된 예제 소개
* 자바카페
자바카페 페이스북 : https://www.facebook.com/groups/javacafe/
자바카페 기술 블로그 : http://tech.javacafe.io/
In this presentation, we are going to discuss how elasticsearch handles the various operations like insert, update, delete. We would also cover what is an inverted index and how segment merging works.
An introduction to elasticsearch with a short demonstration on Kibana to present the search API. The slide covers:
- Quick overview of the Elastic stack
- indexation
- Analysers
- Relevance score
- One use case of elasticsearch
The query used for the Kibana demonstration can be found here:
https://github.com/melvynator/elasticsearch_presentation
오픈소스 검색엔진인 Elasticsearch 어떻게 저장하고 조회하는지 검색엔진의 개념에 대해서 간단히 살펴보고, Node.js 로 구현된 아주 간단한 예제를 소개합니다.
- 검색엔진과 Elasticsearch 소개
- Elasticsearch에서의 색인
- Elasticsearch에서의 조회
- Node.js 로 구현된 예제 소개
* 자바카페
자바카페 페이스북 : https://www.facebook.com/groups/javacafe/
자바카페 기술 블로그 : http://tech.javacafe.io/
In this presentation, we are going to discuss how elasticsearch handles the various operations like insert, update, delete. We would also cover what is an inverted index and how segment merging works.
An introduction to elasticsearch with a short demonstration on Kibana to present the search API. The slide covers:
- Quick overview of the Elastic stack
- indexation
- Analysers
- Relevance score
- One use case of elasticsearch
The query used for the Kibana demonstration can be found here:
https://github.com/melvynator/elasticsearch_presentation
Deep Dive on ElasticSearch Meetup event on 23rd May '15 at www.meetup.com/abctalks
Agenda:
1) Introduction to NOSQL
2) What is ElasticSearch and why is it required
3) ElasticSearch architecture
4) Installation of ElasticSearch
5) Hands on session on ElasticSearch
Talk given for the #phpbenelux user group, March 27th in Gent (BE), with the goal of convincing developers that are used to build php/mysql apps to broaden their horizon when adding search to their site. Be sure to also have a look at the notes for the slides; they explain some of the screenshots, etc.
An accompanying blog post about this subject can be found at http://www.jurriaanpersyn.com/archives/2013/11/18/introduction-to-elasticsearch/
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Edureka!
( ELK Stack Training - https://www.edureka.co/elk-stack-trai... )
This Edureka Elasticsearch Tutorial will help you in understanding the fundamentals of Elasticsearch along with its practical usage and help you in building a strong foundation in ELK Stack. This video helps you to learn following topics:
1. What Is Elasticsearch?
2. Why Elasticsearch?
3. Elasticsearch Advantages
4. Elasticsearch Installation
5. API Conventions
6. Elasticsearch Query DSL
7. Mapping
8. Analysis
9 Modules
The talk covers how Elasticsearch, Lucene and to some extent search engines in general actually work under the hood. We'll start at the "bottom" (or close enough!) of the many abstraction levels, and gradually move upwards towards the user-visible layers, studying the various internal data structures and behaviors as we ascend. Elasticsearch provides APIs that are very easy to use, and it will get you started and take you far without much effort. However, to get the most of it, it helps to have some knowledge about the underlying algorithms and data structures. This understanding enables you to make full use of its substantial set of features such that you can improve your users search experiences, while at the same time keep your systems performant, reliable and updated in (near) real time.
ElasticSearch introduction talk. Overview of the API, functionality, use cases. What can be achieved, how to scale? What is Kibana, how it can benefit your business.
Introduction to Elastic Search
Elastic Search Terminology
Index, Type, Document, Field
Comparison with Relational Database
Understanding of Elastic architecture
Clusters, Nodes, Shards & Replicas
Search
How it works?
Inverted Index
Installation & Configuration
Setup & Run Elastic Server
Elastic in Action
Indexing, Querying & Deleting
elasticsearch의 기본적인 working에 대한 발표자료입니다.
특히나 logging보다는 '검색 서비스'에 포커싱된 자료이기 때문에 '한글검색' 으로 고통받으실 분들을 위한 기초 자료라 생각해주시면 감사하겠습니다.
맞지않는 정보와 오탈자 그리고 의문점이 든다면 dydwls121200@gmail.com으로 언제든지 가벼운 마음으로 메일주세요. 저 또한 성장시키는 일이기도 하니까요. 환영합니다.
효과적인 NoSQL (Elasticahe / DynamoDB) 디자인 및 활용 방안 (최유정 & 최홍식, AWS 솔루션즈 아키텍트) :: ...Amazon Web Services Korea
대량의 트랜잭션을 빠르고 유연하게 처리하기 위해서는, 데이터 처리 및 저장 방식에 대한 변화를 고려해야 합니다. 본 세션에서는 어플리케이션이 요구하는 다양한 사용 패턴 및 성능 요구사항을 살펴보고, NoSQL(Elasticache Redis, DynamoDB)을 기반으로 이를 효율적으로 처리하기 위한 디자인 및 쿼리 패턴을 포함한 기술적 고려사항을 알아봅니다.
Deep Dive on ElasticSearch Meetup event on 23rd May '15 at www.meetup.com/abctalks
Agenda:
1) Introduction to NOSQL
2) What is ElasticSearch and why is it required
3) ElasticSearch architecture
4) Installation of ElasticSearch
5) Hands on session on ElasticSearch
Talk given for the #phpbenelux user group, March 27th in Gent (BE), with the goal of convincing developers that are used to build php/mysql apps to broaden their horizon when adding search to their site. Be sure to also have a look at the notes for the slides; they explain some of the screenshots, etc.
An accompanying blog post about this subject can be found at http://www.jurriaanpersyn.com/archives/2013/11/18/introduction-to-elasticsearch/
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Edureka!
( ELK Stack Training - https://www.edureka.co/elk-stack-trai... )
This Edureka Elasticsearch Tutorial will help you in understanding the fundamentals of Elasticsearch along with its practical usage and help you in building a strong foundation in ELK Stack. This video helps you to learn following topics:
1. What Is Elasticsearch?
2. Why Elasticsearch?
3. Elasticsearch Advantages
4. Elasticsearch Installation
5. API Conventions
6. Elasticsearch Query DSL
7. Mapping
8. Analysis
9 Modules
The talk covers how Elasticsearch, Lucene and to some extent search engines in general actually work under the hood. We'll start at the "bottom" (or close enough!) of the many abstraction levels, and gradually move upwards towards the user-visible layers, studying the various internal data structures and behaviors as we ascend. Elasticsearch provides APIs that are very easy to use, and it will get you started and take you far without much effort. However, to get the most of it, it helps to have some knowledge about the underlying algorithms and data structures. This understanding enables you to make full use of its substantial set of features such that you can improve your users search experiences, while at the same time keep your systems performant, reliable and updated in (near) real time.
ElasticSearch introduction talk. Overview of the API, functionality, use cases. What can be achieved, how to scale? What is Kibana, how it can benefit your business.
Introduction to Elastic Search
Elastic Search Terminology
Index, Type, Document, Field
Comparison with Relational Database
Understanding of Elastic architecture
Clusters, Nodes, Shards & Replicas
Search
How it works?
Inverted Index
Installation & Configuration
Setup & Run Elastic Server
Elastic in Action
Indexing, Querying & Deleting
elasticsearch의 기본적인 working에 대한 발표자료입니다.
특히나 logging보다는 '검색 서비스'에 포커싱된 자료이기 때문에 '한글검색' 으로 고통받으실 분들을 위한 기초 자료라 생각해주시면 감사하겠습니다.
맞지않는 정보와 오탈자 그리고 의문점이 든다면 dydwls121200@gmail.com으로 언제든지 가벼운 마음으로 메일주세요. 저 또한 성장시키는 일이기도 하니까요. 환영합니다.
효과적인 NoSQL (Elasticahe / DynamoDB) 디자인 및 활용 방안 (최유정 & 최홍식, AWS 솔루션즈 아키텍트) :: ...Amazon Web Services Korea
대량의 트랜잭션을 빠르고 유연하게 처리하기 위해서는, 데이터 처리 및 저장 방식에 대한 변화를 고려해야 합니다. 본 세션에서는 어플리케이션이 요구하는 다양한 사용 패턴 및 성능 요구사항을 살펴보고, NoSQL(Elasticache Redis, DynamoDB)을 기반으로 이를 효율적으로 처리하기 위한 디자인 및 쿼리 패턴을 포함한 기술적 고려사항을 알아봅니다.
– Elastic stack과 Data pipeline의 개념
– 데이터의 종류와 형태 / Document 데이터 모델링 (mapping, data type)
– 분산 데이터 저장소 관점에서의 Elasticsearch (index, shard & replica, segment)
https://learningspoons.com/course/detail/elastic-stack/
8. 8
아파치 루씬 (Apache Lucene)
• Created by - Doug Cutting
• Written in - Java
• Apache Solr, Elasticsearch
9. 9
RDBMS 에서는 데이터를 테이블 형태로 저장합니다.
열을 기준으로 인덱스를 만듭니다.
책의 맨 앞에 있는 제목 리스트와 같습니다.
DOC TEXT
1 The quick brown fox jumps over the lazy dog
2 Fast jumping rabbits
10. 10
검색엔진에서는 inverted index 라는 구조로 저장합니다.
RDBMS 와 반대 구조입니다.
텍스트를 다 뜯어서 검색어 사전을 만듭니다.
책의 맨 뒤에 있는 페이지를 가리키는 키워드 같습니다.
TOKEN (TERM) DOC TOKEN (TERM) DOC
Fast 2 jumps 1
The 1 lazy 1
brown 1 over 1
dog 1 quick 1
fox 1 rabbits 2
jumping 2 the 1
11. 11
실제로는 이렇게 저장됩니다.
텍스트를 저장할 때 몇가지 처리 과정을 거칩니다.
TOKEN (TERM) DOC TOKEN (TERM) DOC
brown 1 lazi 1
dog 1 over 1
fast 1 , 2 quick 1 , 2
fox 1 rabbit 2
jump 1 , 2
12. 12
텍스트 처리 과정
대소문자를 변환 합니다.
TOKEN (TERM) DOC TOKEN (TERM) DOC
Fast fast 2 jumps 1
The the 1 lazy 1
brown 1 over 1
dog 1 quick 1
fox 1 rabbits 2
jumping 2 the 1
13. 13
텍스트 처리 과정
토큰을 (보통 ascii 순서로) 재 정렬합니다.
TOKEN (TERM) DOC TOKEN (TERM) DOC
brown 1 lazy 1
dog 1 over 1
fast 2 quick 1
fox 1 rabbits 2
jumping 2 the 1
jumps 1 the 1
14. 14
텍스트 처리 과정
불용어(stopwords, 검색어로서의 가치가 없는 단어들) 를 제거합니다.
a, an, are, at, be, but, by, do, for, i, no, the, to … 등등
TOKEN (TERM) DOC TOKEN (TERM) DOC
brown 1 lazy 1
dog 1 over 1
fast 2 quick 1
fox 1 rabbits 2
jumping 2 the 1
jumps 1 the 1
15. 15
텍스트 처리 과정
형태소 분석 과정을 거칩니다.
보통 ~s, ~ing 등을 제거하는 과정입니다.
한글은 의미 분석을 해야 해서 좀 더 복잡합니다.
TOKEN (TERM) DOC TOKEN (TERM) DOC
brown 1 lazy lazi 1
dog 1 over 1
fast 2 quick 1
fox 1 rabbits rabbit 2
jumping jump 2
jumps jump 1
16. 16
텍스트 처리 과정
jumping, jumps가 jump 로 똑같이 바뀌었으므로 토큰을 병합 해 줍니다.
TOKEN (TERM) DOC TOKEN (TERM) DOC
brown 1 lazi 1
dog 1 over 1
fast 2 quick 1
fox 1 rabbit 2
jump 1 , 2
17. 17
텍스트 처리 과정
동의어를 처리합니다.
TOKEN (TERM) DOC TOKEN (TERM) DOC
brown 1 lazi 1
dog 1 over 1
fast 1 , 2 quick 1 , 2
fox 1 rabbit 2
jump 1 , 2
18. 18
검색 과정
검색어도 똑같이 텍스트 처리를 합니다.
“The lazy spiders” 라고 검색하면
The lazy rabbits
lazi
rabbit
1
DOC TEXT
1 The quick brown fox jumps over the lazy dog
2 Fast jumping rabbits
2
20. 20
Elasticsearch 클러스터링 과정
대용량 검색을 위해서는 클러스터링이 필요합니다.
Elasticsearch는 데이터를 샤드(Shard) 단위로 분리해서 저장합니다.
10 2
3 4
노드 (Node)
Elasticsearch 실행 프로세스
샤드 (Shard)
루씬 검색 쓰레드
22. 22
20 1 4 3
Elasticsearch 클러스터링 과정
샤드들은 각각의 노드들에 분배되어 저장됩니다.
23. 23
20 3 41 04 13 2
무결성과 가용성을 위해 샤드의 복제본을 만듭니다.
같은 내용의 복제본과 샤드는 서로 다른 노드에 저장됩니다.
Elasticsearch 클러스터링 과정
24. 24
20 3 41 04 13 2
시스템 다운이나 네트워크 단절 등으로 유실된 노드가 생기면
Elasticsearch 클러스터링 과정
25. 25
20 3 41 04 13 2
4
0
복제본이 없는 샤드들은 다른 살아있는 노드로 복제를 시작합니다.
Elasticsearch 클러스터링 과정
26. 26
20 3 41 13 2
4
0
노드의 수가 줄어들어도 샤드의 수는 변함 없이 무결성을 유지합니다.
Elasticsearch 클러스터링 과정
27. 27
20 3 41 13 2
4
0
처음 쿼리 수행 명령을 받은 노드는 모든 샤드에게 쿼리를 전달합니다.
1차적으로 모든 샤드(또는 복제본에서) 검색을 실행합니다.
검색 과정 – Query Phase
client
28. 28
20 3 41 13 2
4
0
“from + size” 크기의 결과 큐를 처음 명령 받은 노드로 리턴합니다.
리턴된 결과는 루씬 doc id 와 랭킹 점수만 가지고 있습니다.
노드는 리턴된 결과들을 가지고 랭킹 점수 기반으로 정렬합니다.
검색 과정 – Query Phase
client
29. 29
20 3 41 13 2
4
0
정렬된 값 기반으로 유효한 샤드들에 검색 결과들을 요청합니다.
검색 과정 – Fetch Phase
client
30. 30
20 3 41 13 2
4
0
전체 문서 내용(_source) 등의 정보가 리턴되어 클라이언트로 전달됩니다.
검색 과정 – Fetch Phase
client
33. 33
TF / IDF
• Term Frequency
‒ 찾는 검색어가 문서에 많을수록 해당 문서의 정확도가 높습니다.
• Inverse Document Frequency
‒ 전체 문서에서 많이 출현한 (흔한) 단어일수록 점수가 낮습니다.
Term Frequency / Inverse Document Frequency
34. 34
검색 랭킹이 중요한 이유
• 사용자들은 대부분 처음 나온 결과만 봅니다.
• 결과값이 큰 내용을 fetch 하는 것은 상당히 부하가 큽니다.
• 1~1,000 을 fetch 하는 것이나 990~1,000 을 fetch 하는 것이나 쿼리 작업
규모가 비슷합니다.
• 구글도 랭킹이 중요하긴 마찬가지…
2017 데이터야 놀자
35. 35
루씬 세그먼트(Segment)
Inverted Index, Doc Value, 원본 문서 등등을 저장하고 있는 단위 파일입니다.
샤드 세그먼트문서
• 루씬은 inverted index를 하나의 거
대한 파일이 아니라 여러개의 작은
파일 단위로 저장합니다.
• 입력 버퍼가 가득 차거나, 1초 마다
하나씩 생성됩니다.
• 한번 생성된 세그먼트는 변경되지
않습니다. (immutable)
36. 36
문서 변경/삭제 과정
• update는 없습니다. 모두 delete & insert 입니다.
• 문서를 삭제하면 삭제되었다는 상태만 표시하고 검색에서 제외합니다.
• 나중에 세그먼트 병합 과정에서 삭제된 문서를 빼고 나머지 문서들을 모아
새로운 세그먼트를 만듭니다.
‒ 그래서 문서를 삭제 하더라도 세그먼트 병합을 하기 전 까지 스토리지 용량은 줄어들지 않
습니다.
• 세그먼트 병합은 비용이 큰 동작입니다.
‒ 디스크 I/O 작업입니다.
‒ 시스템이 느려집니다.
‒ 가능하면 사용자들이 적은 시간에 하는것이 좋습니다.
한먼 생성된 세그먼트는 변경되지 않습니다.
저는 현재 Elastic 이라는 오픈소스 검색엔진 회사에서 Tech Evangelist 로 일을 하고 있습니다.
Tech Evangelist 를 딱히 정의하기는 어려운데, 저는 입개발자 라고 보통 이야기 하고요, 해당 기술을 잘 모르던 사람에게 해당 기술 또는 제품에 대한 흥미를 불어넣어 주는 것이 가장 중요한 역할이라고 할 수 있을 것 같습니다. 영업, 기술영업들과는 약간 다른데요, 영업들은 보통 숫자(돈, 기간 등)를 가지고 이야기를 하고요, 저희는 보통 그런것을 배제하고 코어 기술들에 대한 이야기들을 합니다. 그래서 커뮤니티 밋업 이나 컨퍼런스 같은 곳에서 발표를 하는 것이 중요한 Action Item 입니다.