Post

ES ElasticSearch (3)

ElasticSearch 형태소 분석기


ElasticSearch analysis-nori

  • 한글형태소 분석기는 아리랑, 은전한닢, Open korean text, Nori가 있다. 그 중 ElasticSearch에서 개발하여 제공하는 Nori를 설치하여 사용해보기로 했다.

  • Nori는 루씬을 기반으로 만들어졌으며, 은전한닢에서 사용하는 사전을 재가공하여 사용하고 있다.

analysis-nori 설치 🔧

1
2
3
4
5
6
7
C:\elasticsearch-7.9.2-windows-x86_64\elasticsearch-7.9.2\bin>elasticsearch-plugin install analysis-nori

//result
-> Installing analysis-nori
-> Downloading analysis-nori from elastic
[=================================================] 100%??
-> Installed analysis-nori
  • 다음과 같은 명령어를 실행하면 analysis-noriinstall한다.

  • 설치가 완료 됐으면 Elasticsearch Service를 재실행하여 정상적으로 Nori Plugin이 설치 되었는지 확인한다.

analysis-nori 확인하기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//URL - GET Method
http://127.0.0.1:9200/_analyze

//RequestBody
{
    "tokenizer": "nori_tokenizer",
    "text":  "모두들 화이팅"
}

//Response
{
    "tokens": [
        {
            "token": "모두",
            "start_offset": 0,
            "end_offset": 2,
            "type": "word",
            "position": 0
        },
        {
            "token": "들",
            "start_offset": 2,
            "end_offset": 3,
            "type": "word",
            "position": 1
        },
        {
            "token": "화이팅",
            "start_offset": 4,
            "end_offset": 7,
            "type": "word",
            "position": 2
        }
    ]
}
  • 다음과 같이 Get api 요청을 보내고, text의 문자가 토큰화 됐으면 성공!
This post is licensed under CC BY 4.0 by the author.