LoginSignup
4
3

More than 3 years have passed since last update.

WordPressで検索エンジンをElasticSearchにするまで

Last updated at Posted at 2020-11-24

WordPressの検索エンジンをパワーアップしたい...

そんな方に検索エンジンElasticSearchをおすすめします。
手順はいたって簡単
1. ElasticSearchServiceの用意
2. WPにElasticPressプラグインを導入
3. ElasticSearchとElasticPressの連携
4. インデックスの作成
5. 日本語最適化(Kuromoji)

ElasticSearchServiceの用意

そもそもElasticSearchServiceとは?を知りたい方は以下参照
Amazon Elasticsearch Service
導入手順は、人がやってくれているので以下参照
https://qiita.com/takayuki-miura0203/items/c2ad9527d818fd20ca93

注意点は、2点
・http接続を許可すること
細かいアクセスコントロールをオフにするを選択し、 HTTPSの要求をオフにしておきましょう。
(後述するElasticPressにつながらない現象が発生する)
image.png

・インスタンスタイプを小さくしたほうがいいという点(時間課金なのに止めることはできないので)

ドメインが立ち上がったら、エンドポイントをメモしておいてください
WPとの接続に使用します。

WPにElasticPressプラグインを導入

プラグイン管理画面で、ElasticPressを検索しインストール

ElasticSearchServiceとElasticPressの連携

WPにて、管理画面サイドバーにElasticPress>settingを選択し、設定画面に入る
ElasticPress.ioではなくThirdPartyを選択し、ElasticsearchHostURLにElasticSearchServiceのエンドポイント名を入力
image.png
その後、画面上部の同期ボタンを押下することでインデックスが作成される。
image.png

日本語最適化(Kuromoji)

ElasticSearchを日本語に最適化するためには形態素解析などが必要
それらをKuromojiといったプラグインが行ってくれる
そもそもElasticSearchに求められる形態素解析ってなにをやっているかは以下を参照
https://qiita.com/kouyaf77@github/items/7d22f224e82520514ec7
https://sssslide.com/speakerdeck.com/kunihikokido/developers-dot-io-2016-c-2-elasticsearchdezi-you-zi-zai-nijian-suo-fen-xi-dekiruyouninarutamefalsehinto
https://medium.com/hello-elasticsearch/elasticsearch-833a0704e44b#.qnax0vuwt

どうやって、ElasticPressでやるのかについては以下の記事を参照
https://www.arigato.es/elasticpress%e6%97%a5%e6%9c%ac%e8%aa%9e%e8%a8%ad%e5%ae%9a/
注意点は、5-2.phpを編集するのではなく7-0.phpを編集すること(おそらくphp or WPのバージョンによってファイルを使い分けている)(当環境はWPのバージョンが5.0以上)

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