LoginSignup
8
8

More than 5 years have passed since last update.

ElasticSearch 1.x インストール (kuromojiも添えて)

Last updated at Posted at 2014-07-23

ふとマルコフ連鎖で一人で語れるおっさん作りたくなったので、elasticsearchをインスコしてみた。
elasticsearch1.xで入れています。

環境

  • CentOS

注意事項

参考にしたサイト

yumで入れれるようにreposを追加する

/etc/yum.repos.d/elasticsearch.repo
[elasticsearch-1.0]
name=Elasticsearch repository for 1.0.x packages
baseurl=http://packages.elasticsearch.org/elasticsearch/1.0/centos
gpgcheck=1
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
enabled=1

インスコ

sudo yum install elasticsearch

kuromoji head pluginのインストール

日本人なので日本語使いたいのでkuromoji使う

/usr/share/elasticsearch/bin
sudo /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-analysis-kuromoji/2.0.0.RC1
sudo /usr/share/elasticsearch/bin/plugin -install head

elasticsearch 起動

sudo /etc/init.d/elasticsearch start

動作確認

curl -XGET localhost:9200

{
  "status" : 200,
  "name" : "Silver Samurai",
  "version" : {
    "number" : "1.0.3",
    "build_hash" : "61bfb72d845a59a58cd9910e47515665f6478a5c",
    "build_timestamp" : "2014-04-16T14:43:11Z",
    "build_snapshot" : false,
    "lucene_version" : "4.6"
  },
  "tagline" : "You Know, for Search"
}   

index 作ってみる

curl -X PUT localhost:9200/test -d '
{
  "mappings": {
    "entry": {
      "properties": {
        "title": {
          "type": "string",
          "analyzer": "kuromoji"
        },
        "body": {
          "type": "string",
          "analyzer": "kuromoji"
        },
        "url": {
          "type": "string"
        }
      }
    }
  }
}'

# これが帰ってくればOK!!
{"acknowledged":true}

分かち書きの確認

curl -XGET 'localhost:9200/test/_analyze?analyzer=kuromoji&pretty' -d '関西国際空港'

{
  "tokens" : [ {
    "token" : "関西",
    "start_offset" : 0,
    "end_offset" : 2,
    "type" : "word",
    "position" : 1
  }, {
    "token" : "関西国際空港",
    "start_offset" : 0,
    "end_offset" : 6,
    "type" : "word",
    "position" : 1
  }, {
    "token" : "国際",
    "start_offset" : 2,
    "end_offset" : 4,
    "type" : "word",
    "position" : 2
  }, {
    "token" : "空港",
    "start_offset" : 4,
    "end_offset" : 6,
    "type" : "word",
    "position" : 3
  } ]
}

elasticsearch インストールでググると0.x系のネタが多くes1.x系入れようとすると
kuromojiがうまく動作しなかったのでメモ程度に

8
8
0

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
8
8