LoginSignup
10
4

More than 5 years have passed since last update.

Crowiで検索を有効化する(CentOS 6.8)

Last updated at Posted at 2016-10-31

Crowiで検索を有効化する

Crowiシリーズの3本目である。

  1. Crowiをセットアップする(CentOS 6.8)
  2. CrowiでGoogleAppsでのログインを有効化する

version1.5.0から実装された検索機能を使用する。

環境

  • CentOS 6.8
  • Java 1.7 (1.6で動かそうとして失敗した)
  • Crowi v1.5.0

Elasticsearchを導入する

検索機能を使用するにはElasticserachが必要だそうなのでこれを導入する。

レポジトリの設定

  1. yumレポジトリの設定
    $ rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

  2. レポジトリの設定を書き換える

/etc/yum.repos.d/elasticsearch.repo
[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=http://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
  • イントール
    $ yum install elasticsearch

  • 日本語対応するためにanalysis-kuromojiをいれる ここでつまる

$ cd /usr/share/elasticsearch
$ bin/plugin install analysis-kuromoji
  • javaが1.7以上じゃないと動かないらしい
    $ yum install java-1.7.0-openjdk

  • もっかいkuromojiをいれる
    $ bin/plugin install analysis-kuromoji

  • Elasticsearchを再起動
    $ /etc/init.d/elasticsearch start

  • 自動起動を設定する
    $ chkconfig --add elasticsearch

  • 設定を変更する
    /etc/elasticsearch/elasticsearch.ymlを書き換える

/etc/elasticsearch/elasticsearch.yml
 # network.host: 192.168.0.1
network.host: YOURIP
  • 書き換えたらリスタートを忘れずに
    $ /etc/init.d/elasticsearch restart

  • Elasticsearchとkuromojiの動作確認をする
    Elasticsearch

Elasticsearch
$ curl 'http://YOURIP:9200/'      
{
  "name" : "Gosamyr",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "RT6I6Z3JSliJ_UZdSkvcnQ",
  "version" : {
    "number" : "2.4.1",
    "build_hash" : "c67dc32e24162035d18d6fe1e952c4cbcbe79d16",
    "build_timestamp" : "2016-09-27T18:57:55Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

kuromoji

kuromoji
 $ curl -X GET 'http://YOURIP:9200/_nodes/plugins?pretty'
{
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "q7PccHeCTLGVDhJ5Pd34Gg" : {
      "name" : "Gosamyr",
      "transport_address" : "160.16.125.226:9300",
      "host" : "160.16.125.226",
      "ip" : "160.16.125.226",
      "version" : "2.4.1",
      "build" : "c67dc32",
      "http_address" : "160.16.125.226:9200",
      "plugins" : [ {
        "name" : "analysis-kuromoji",
        "version" : "2.4.1",
        "description" : "The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch.",
        "jvm" : true,
        "classname" : "org.elasticsearch.plugin.analysis.kuromoji.AnalysisKuromojiPlugin",
        "isolated" : true,
        "site" : false
      } ],
      "modules" : [ {
        "name" : "lang-expression",
        "version" : "2.4.1",
        "description" : "Lucene expressions integration for Elasticsearch",
        "jvm" : true,
        "classname" : "org.elasticsearch.script.expression.ExpressionPlugin",
        "isolated" : true,
        "site" : false
      }, {
        "name" : "lang-groovy",
        "version" : "2.4.1",
        "description" : "Groovy scripting integration for Elasticsearch",
        "jvm" : true,
        "classname" : "org.elasticsearch.script.groovy.GroovyPlugin",
        "isolated" : true,
        "site" : false
      }, {
        "name" : "reindex",
        "version" : "2.4.1",
        "description" : "_reindex and _update_by_query APIs",
        "jvm" : true,
        "classname" : "org.elasticsearch.index.reindex.ReindexPlugin",
        "isolated" : true,
        "site" : false
      } ]
    }
  }
}
  • crowi側で読ませる
/etc/sysconfig/crowi
ELASTICSEARCH_URI=http://YOURIP:9200

Crowi側の設定

秒でおわる
1. forever start app.js
2. CrowiのGUIから"管理" -> "検索管理" -> "Build Now"

完成
スクリーンショット 2016-10-31 18.25.22.png

参考

Elasticsearch を yumでインストール (CentOS)
Crowi v1.5.0 にアップデートしてみた

10
4
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
10
4