Relevanssiは、WordPressの検索機能を強化することができるプラグインです。検索機能をかなり細かくカスタマイズすることが可能です。
Relevanssiのインストール
インストール手順は以下の通りです。
- Relevanssiをダウンロードします。
- ダウンロードしたファイルを展開し wp-content/plugins にアップロードします。
- 管理画面の[プラグイン]ページで、Relevanssiを有効化します。
Relevanssiの設定
Relevanssiを有効化したら、[設定] – [Relevanssi]で設定を行います。
Basic options
Relevanssiの全般設定です。
| Use search for admin | 管理者の使用 |
| Default operator for the search? | デフォルト演算子 |
| Disable OR fallback | AND検索で結果がない時にOR検索に切り替えない |
| Default order for results | 検索結果の並び順 |
| When to use fuzzy matching? | あいまい検索 |
| Limit searches | 検索結果を500件までに制限 |
Weights
重み付けの設定です。各項目の重要度を数値で設定します。
Logs
ログの設定です。
| Keep a log of user queries | 検索クエリの記録 |
| Log the user’s IP with the queries | 検索ユーザーのIPアドレスの記録 |
| Don’t log queries from these users | ログを記録しないユーザーのユーザーIDもしくはユーザー名 |
Exclusions and restrictions
検索の除外と制限についての設定です。
| Restrict search to these categories and tags | カテゴリーとタグの検索制限 |
| Exclude these categories from search | 検索からカテゴリーを除外 |
| Exclude these tags from search | 検索からタグを除外 |
| Exclude these posts/pages from search | 検索から投稿・固定ページを除外 |
| Respect exclude_from_search for custom post types | exclude_from_searchがtrueの投稿タイプを除外 |
Custom excerpts/snippets
検索結果の抜粋について設定します。
| Create custom search result snippets | 検索結果の抜粋を作成 |
| Length of the snippet | 検索結果の抜粋の長さ |
| Allowable tags in excerpts | 抜粋で許可するHTMLタグ |
| Show breakdown of search hits in excerpts | 詳細情報の表示 |
| The breakdown format | 詳細情報のフォーマット |
Search hit highlighting
検索キーワードの強調表示について設定します。
| Highlight query terms in search results | 検索キーワードの強調 |
| Highlight query terms in result titles too | タイトル内の検索キーワードを強調 (the_title()をrelevanssi_the_title()に置き換える必要あり) |
| Highlight query terms in documents from local searches | 検索結果から投稿を開いた時に本文内の検索キーワードを強調 |
| Highlight query terms in comments | 検索結果から投稿を開いた時にコメント内の検索キーワードを強調 |
| Uncheck this if you use non-ASCII characters | 非ASCII文字でハイライトが機能しない場合はチェック |
| Text color for highlights | 強調時の文字色 |
| Background color for highlights | 強調時の背景色 |
| CSS style for highlights | 強調文字に適用するCSS |
| CSS class for highlights | 強調文字に追加するクラス名 |
Indexing options
インデックスに関する設定です。インデックスする投稿タイプやカテゴリー等にチェックを入れます。
| Minimum word length to index | インデックスする最低文字数 |
| Expand shortcodes in post content | ショートコードの展開 |
| Index and search your posts’ authors | 著者のインデックス |
| Index and search post excerpts | 抜粋のインデックス |
| Index and search these comments | コメントのインデックス |
| Custom fields to index | カスタムフィールドのインデックス |
一通り設定が完了したら、[Build the index]をクリックしてインデックスを作成しておきましょう。
あとがき
WordPress標準の検索機能はお世辞にもクオリティが高いとは言えませんので、こういったプラグインを使って強化することで有用性が向上しますね。
WordPressサイトの検索機能を強化したいときは、ぜひご活用ください。

