개발/Elasticsearch

데이터 색인, analyze API, Nori 설치하기

지니.air 2023. 12. 11. 11:21

데이터 색인(Index)

- Elasticsearch : 데이터를 저장할 때 색인을 거쳐서 저장이 된다.

- 데이터를 저장하고 있는 공간을 색인이라고 했음

- 색인 과정..(Elasticsearch가 어떤 구조로 데이터를 저장 + 사용하는지)

 

역인덱스, Inverted Index

- *** Elasticsearch에 대한 대답

- 검색에 대해 용이한 구조로 되어 있다.

https://esbook.kimjmin.net/06-text-analysis/6.2-text-analysis

 

6.2 텍스트 분석 - Text Analysis - Elastic 가이드북

텀 중에는 검색어로서의 가치가 없는 단어들이 있는데 이런 단어를 불용어(stopword) 라고 합니다. 보통 a, an, are, at, be, but, by, do, for, i, no, the, to … 등의 단어들은 불용어로 간주되어 검색어 토큰

esbook.kimjmin.net

 

analyze API

- 임시로 애널라이저의 적용을 확인하는 도구

 

영어 형태소 분석기 : snowball

한글 형태소 분석기 

- ES 6.X 적용 > Nori 형태소 분석 채택

 

Nori 설치하기

(우분투에서하기)

$ cd /usr/share/elasticsearch

$ sudo bin/elasticsearch-plugin install analysis-nori

재시작해야 적용

$ sudo systemctl restart elasticsearch

 

GET my_nori/_analyze
{
"text": "백두산이",
"tokenizer": "nori_tokenizer"
}

nori_tokenizer

GET my_nori/_analyze
{
"text": "백두산이",
"tokenizer": "nori_none"
}

nori_none

GET my_nori/_analyze
{
"text": "백두산이",
"tokenizer": "nori_discard"
}

nori_discard

GET my_nori/_analyze
{
"text": "백두산이",
"tokenizer": "nori_mixed"
}

nori_mixed

GET _analyze
{
"tokenizer": "nori_tokenizer",
"text": "春夏秋冬",
"filter": [ "nori_readingform" ]
}

"filter": [ "nori_readingform" ]