open-korean-text / elasticsearch-analysis-openkoreantext

Korean analysis plugin that integrates open-korean-text module into elasticsearch.
Apache License 2.0
126 stars 22 forks source link

디폴트 애널라이저로 설정하는 방법도 설명에 좀 추가해주세요 #10

Closed roh0sun closed 6 years ago

roh0sun commented 6 years ago

디폴트 애널라이저로 설정하는 방법도 설명에 좀 추가해주세요.

curl -XPUT http://localhost:9200/my_index?pretty -d '{
  "settings": {
    "analysis": {
      "analyzer": {
        "default": {
          "type": "custom",
          "tokenizer": "openkoreantext-tokenizer",
          "char_filter": "openkoreantext-normalizer",
          "filter": [
             "openkoreantext-stemmer",
             "openkoreantext-redundant-filter",
             "openkoreantext-phrase-extractor"
          ]
        }
      }
    }
  }
}'

이런 식으로 해야 하는 거 맞죠? 이렇게 해서,

curl -XGET http://localhost:9200/my_index/_analyze?pretty -d "한국어를 처리하는 예시입니닼ㅋㅋ"
=>
{
  "tokens" : [
    {
      "token" : "한국어처리",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "Noun",
      "position" : 0
    },
    {
      "token" : "예시",
      "start_offset" : 10,
      "end_offset" : 12,
      "type" : "Noun",
      "position" : 1
    },
    {
      "token" : "한국어",
      "start_offset" : 0,
      "end_offset" : 3,
      "type" : "Noun",
      "position" : 2
    },
    {
      "token" : "처리",
      "start_offset" : 5,
      "end_offset" : 7,
      "type" : "Noun",
      "position" : 3
    }
  ]
}

이렇게 나오는 건 확인했는데, 한참 헤맸습니다 ㅠㅠ

keepcosmos commented 6 years ago

네, 결과는 제대로 나오고 있는게 맞습니다. 👍 default analyzer 로 설정 혹은 커스텀하는 부분은 ES 도큐먼트를 참고하는게 맞는거 같아요.

감사합니다 :)