LoginSignup
22

More than 5 years have passed since last update.

ElasticSearchでICU Transliteratorを使う

Last updated at Posted at 2014-03-16

ドキュメントに記載はされてないのですが、elastic-analysis-icuから利用可能.
今回は、カタカナ→ひらがなの変換をするフィルタを設定してみます

  • elasticsearch-analysis-icuをインストトールする
bin/plugin -install elasticsearch/elasticsearch-analysis-icu/2.0.0
  • フィルタ・アナライザを登録する(アナライザは用途に応じて任意に)
curl -XPUT localhost:9200/test/ --data-binary @setting.json
setting.json
{
    "settings": {
        "analysis": {
            "analyzer": {
                "test_analyzer": {
                    "tokenizer": "keyword",
                    "filter" : ["kana_filter"]
                }
            },
            "filter": {
                 "kana_filter" : {
                    "type" : "icu_transform",
                    "id": "Katakana-Hiragana"
                 }
            }
        }
    }
}
  • 動作確認
curl -XGET 'localhost:9200/test/_analyze?analyzer=test_analyzer&pretty' -d 'カレーライス'
{
  "tokens" : [ {
    "token" : "かれえらいす",
    "start_offset" : 0,
    "end_offset" : 6,
    "type" : "word",
    "position" : 1
  } ]
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22