Install the Nori

[nori install]


elasticsearch shutdown

#ES_HOME/bin/elasticsearch-plugin install analysis-nori


[nori dictionary files]


$ES_HOME/config/dictionary/user.txt (사용자사전)

이동길

홍길동                                   # 사용자 단어

삼성전자 삼성 전자             # 복합명사


$ES_HOME/config/dictionary/synonym.txt (동의어사전)

Elasticsearch, 엘라스틱서치         # 동의어

Apple -> 사과                                # 치환


$ES_HOME/config/dictionary/stopword.txt (불용어사전)

바보

개새끼


[index settings]


"settings": {

    "number_of_shards": 1,

    "number_of_replicas": 0,

    "analysis": {

      "analyzer": {

        "nori_mixed": {

          "tokenizer" : "nori_tokenizer_mixed",

          "filter": [

            "nori_synonym",

            "nori_stoptag",

            "nori_stopword"

          ]

        }

      }, 

      "tokenizer": {

        "nori_tokenizer_none": {

          "type": "nori_tokenizer",

          "decompound_mode": "none",

          "user_dictionary": "dictionary/user.txt"

        },

        "nori_tokenizer_discard": {

          "type": "nori_tokenizer",

          "decompound_mode": "discard",

          "user_dictionary": "dictionary/user.txt"

        },

        "nori_tokenizer_mixed": {

          "type": "nori_tokenizer",

          "decompound_mode": "mixed",

          "user_dictionary": "dictionary/user.txt"

        }

      },

      "filter": {

        "nori_synonym": {

          "type": "synonym",

          "synonyms_path": "dictionary/synonym.txt"

        },

        "nori_stoptag": {

          "type": "nori_part_of_speech",

          "stoptags": [

            "E", "IC", "J", "MAG", "MAJ",

            "MM", "SP", "SSC", "SSO", "SC",

            "SE", "XPN", "XSA", "XSN", "XSV",

            "UNA", "NA", "VSV"

          ]

        },

        "nori_stopword": {

          "type": "stop",

          "stopwords_path": "dictionary/stopword.txt"

        }

      }

    }

댓글