MediaWikiにCirrusSearch導入
https://gyazo.com/f4a9545ef56379a650976008b24ba643
動機
全文検索で確実に結果が出るようにしたい
Wikipediaでも使われているすごい検索
ElacsticSearchを使っている
インストール
意外と手順が多いし飛ばすとハマる
日本語情報少なすぎ
# yum -y install java-1.8.0-openjdk-devel
これがないとElasticSearchが入らない
2. ElasticSearchを入れる(最新は6.x系だが、5.xまでの対応)
最新のelasticsearch-5.6.14-1.noarch などを入れる
analysis-kuromojiも入れる
起動して動作確認
しばらくはサーバが重いかも
フォルダに移動して composer install --no-dev
composerがなければそれも入れる
バージョンページを開いてエラーがないのを確認
5. インデックスを作成する
Only Elasticsearch 5.x is supported. Your version: 6.5.4.
おい
ElasticSearch6.x入れてしまった時の対処
# vi /etc/yum.repos.d/elasticsearch.repo
# yum downgrade elasticsearch-5.6.14-1.noarch
# /usr/share/elasticsearch/bin/elasticsearch-plugin remove analysis-kuromoji
# /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji
# sudo systemctl restart elasticsearch
# sudo systemctl daemon-reload
code:README
Add this to LocalSettings.php:
wfLoadExtension( 'Elastica' );
require_once( "$IP/extensions/CirrusSearch/CirrusSearch.php" );
$wgDisableSearchUpdate = true;
Configure your search servers in LocalSettings.php if you aren't running Elasticsearch on localhost:
There are other $wgCirrusSearch variables that you might want to change from their defaults.
Now run this script to generate your elasticsearch index:
php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php
Now remove $wgDisableSearchUpdate = true from LocalSettings.php. Updates should start heading to Elasticsearch.
Next bootstrap the search index by running:
php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipLinks --indexOnSkip
php $MW_INSTALL_PATH/extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipParse
Note that this can take some time. For large wikis read "Bootstrapping large wikis" below.
Once that is complete add this to LocalSettings.php to funnel queries to ElasticSearch:
$wgSearchType = 'CirrusSearch';