OKdevTV Docs
Home OKdevTV
ESC
elasticsearch 1 min read 1.9 KB Raw Markdown
On this page (3)

Nori

install plugin

text
cd /path/to/{ES_HOME}
sudo bin/elasticsearch-plugin install analysis-nori

# remove plugin
sudo bin/elasticsearch-plugin remove analysis-nori

custom dictionary

  • config/userdict_ko.txt
text
c++      
C샤프
세종
세종시 세종 시
  • set tokenizer
text
curl -X PUT "localhost:9200/nori_sample" -H 'Content-Type: application/json' -d'
{
  "settings": {
    "index": {
      "analysis": {
        "tokenizer": {
          "nori_user_dict": {
            "type": "nori_tokenizer",
            "decompound_mode": "mixed",
            "user_dictionary": "userdict_ko.txt"
          }
        },
        "analyzer": {
          "my_analyzer": {
            "type": "custom",
            "tokenizer": "nori_user_dict"
          }
        }
      }
    }
  }
}
'
text
curl -X GET "localhost:9200/nori_sample/_analyze" -H 'Content-Type: application/json' -d'
{
  "analyzer": "my_analyzer",
  "text": "세종시"  
}
'
  • 숫자 제외
text
curl -X DELETE "localhost:9200/nori_sample"
curl -X PUT "localhost:9200/nori_sample" -H 'Content-Type: application/json' -d'
{
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "my_analyzer": {
            "tokenizer": "nori_tokenizer",
            "filter": [
              "my_posfilter"
            ]
          }
        },
        "filter": {
          "my_posfilter": {
            "type": "nori_part_of_speech",
            "stoptags": [
              "NR"   
            ]
          }
        }
      }
    }
  }
}
'
text
curl -X GET "localhost:9200/nori_sample/_analyze" -H 'Content-Type: application/json' -d'
{
  "analyzer": "my_analyzer",
  "text": "여섯 용이"  
}
'

ref