「Elasticsearch」の版間の差分

提供:Tsubopedia
編集の要約なし
編集の要約なし
69行目: 69行目:


*設定を保存したら、以下のコマンドを実行し、実行後、$wgDisableSearchUpdate = true;を削除する。
*設定を保存したら、以下のコマンドを実行し、実行後、$wgDisableSearchUpdate = true;を削除する。
<syntaxhighlight lang="bash">  
<syntaxhighlight lang="bash">
Now run this script to generate your elasticsearch index:
Now run this script to generate your elasticsearch index:
  php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php  
  php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php  
75行目: 75行目:


*次に、以下のコマンドを実行し、実行後、$wgSearchType = 'CirrusSearch';をLocalSettings.phpへ追加する。
*次に、以下のコマンドを実行し、実行後、$wgSearchType = 'CirrusSearch';をLocalSettings.phpへ追加する。
<syntaxhighlight lang="bash">  
<syntaxhighlight lang="bash">
  php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipLinks --indexOnSkip
  php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipLinks --indexOnSkip
  php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipParse
  php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipParse
81行目: 81行目:
Once that is complete add this to LocalSettings.php to funnel queries to ElasticSearch:
Once that is complete add this to LocalSettings.php to funnel queries to ElasticSearch:
  $wgSearchType = 'CirrusSearch';
  $wgSearchType = 'CirrusSearch';
</syntaxhighlight>
*Indexの定期更新のためのcron設定
<syntaxhighlight lang="bash">
vi /etc/crontab
0,30 * * * * root /usr/bin/php $mediawikiroot/maintenance/runJobs.php > /var/run/log/runJobs.log 2>&1
</syntaxhighlight>
</syntaxhighlight>


== WordPressでElasticsearchを利用する設定 ==
== WordPressでElasticsearchを利用する設定 ==

2016年2月23日 (火) 07:03時点における版

Elasticsearchは、Elasticのオープンソースソリューションの1つで、Elasticsearchをはじめ、Logstash、Kibana、Beatsなどの、オープンソースプロジェクトを開発・支援している。これらのオープンソースソリューションは、あらゆる業界で課題とされている検索、ログ分析、解析に関する課題を解決する。

AWS(Amazon Linux)へのインストール

  • yumリポジトリの設定
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
  • yumリポジトリの確認
vi /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

上記は、Elasticsearch 2.xをインストールする場合の例。現在、MediawikiのExtensionは2.xをサポートしていないので、1.7をインストールする必要がある。その場合は、以下のリポジトリを使用する。

vi /etc/yum.repos.d/elasticsearch.repo

[elasticsearch-1.7]
name=Elasticsearch repository for 1.7 packages
baseurl=http://packages.elastic.co/elasticsearch/1.7/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1

なお、1.7と2.xのリポジトリは同時に記載可能なので、将来のバージョンアップに備えて、2.xの記述も残しておくことも可能。その場合には、2.xの記述は、enabled=0にする必要がある。

  • yumを利用したインストール
yum install elasticsearch
  • Elasticsearchの起動
service elasticsearch start
  • Elasticsearchの起動確認
curl 'http://localhost:9200/'
  • Kuromojiのインストール

Elasticsearch 1.7に対応した、Kuromoji 2.7.0をインストールする。

cd /usr/share/elasticsearch/
bin/plugin install elasticsearch/elasticsearch-analysis-kuromoji/2.7.0

MediawikiでElasticsearchを利用する設定

  • 使用するExtensions
CirrusSearch
Elastica
  • Indexの作成

上記Extensionsをインストールする過程で、LocalSettings.phpに以下の設定を追加する。

Add this to LocalSettings.php:
 require_once( "$IP/extensions/Elastica/Elastica.php" );
 require_once( "$IP/extensions/CirrusSearch/CirrusSearch.php" );
 $wgDisableSearchUpdate = true;
  • 設定を保存したら、以下のコマンドを実行し、実行後、$wgDisableSearchUpdate = true;を削除する。
Now run this script to generate your elasticsearch index:
 php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php
  • 次に、以下のコマンドを実行し、実行後、$wgSearchType = 'CirrusSearch';をLocalSettings.phpへ追加する。
 php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipLinks --indexOnSkip
 php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipParse

Once that is complete add this to LocalSettings.php to funnel queries to ElasticSearch:
 $wgSearchType = 'CirrusSearch';
  • Indexの定期更新のためのcron設定
vi /etc/crontab
0,30 * * * * root /usr/bin/php $mediawikiroot/maintenance/runJobs.php > /var/run/log/runJobs.log 2>&1

WordPressでElasticsearchを利用する設定