全文検索システム「Hyper Estraier」の導入

「Estraier」の後継である「Hyper Estraier」を導入する。
ここでは
/var/www/html/
以下のすべてを検索対象ディレクトリとし、インデックスを
/var/www/hyperestraier/
に作成するものとする。
なお、「Apache」の設定は完了済みとする。

「Hyper Estraier」のインストール

「Hyper Estraier」のインストール

[root@Fedora ~]# yum -y install hyperestraier <= 「Hyper Estraier」のインストール
「Hyper Estraier」の実行

インデックス格納先ディレクトリの作成

[root@Fedora ~]# mkdir /var/www/hyperestraier

「Hyper Estraier」の新規実行

「Hyper Estraier」を新規に実行する場合は以下のようにする。

[root@Fedora ~]# estcmd gather -il ja -bc -sd /var/www/hyperestraier/crimson-snow /var/www/html <= 文書の登録
[root@Fedora ~]# estcmd create -attr @title str -attr @mdate seq -attr @size seq /var/www/hyperestraier/crimson-snow <= 属性名とデータ型を指定

「Hyper Estraier」の実行

ページに更新があった後、「Hyper Estraier」を実行する場合は以下のようにする。

[root@Fedora ~]# estcmd gather -cl -il ja -bc -sd -cm /var/www/hyperestraier/crimson-snow /var/www/html <= 文書の登録
[root@Fedora ~]# estcmd create -attr @title str -attr @mdate seq -attr @size seq /var/www/hyperestraier/crimson-snow <= 属性名とデータ型を指定
[root@Fedora ~]# estcmd purge -cl /var/www/hyperestraier/crimson-snow <= 削除文書の反映
[root@Fedora ~]# estcmd optimize /var/www/hyperestraier/crimson-snow <= インデックスの最適化
「Hyper Estraier」の設置

設定ファイル等格納先ディレクトリの作成

[root@Fedora ~]# mkdir /var/www/cgi-bin/hyperestraier

各種ファイルのコピー

[root@Fedora ~]# cp /usr/libexec/estseek.cgi /var/www/cgi-bin/hyperestraier/estseek.cgi
[root@Fedora ~]# cp /usr/share/hyperestraier/locale/ja/estseek.conf /var/www/cgi-bin/hyperestraier/estseek.conf
[root@Fedora ~]# cp /usr/share/hyperestraier/locale/ja/estseek.tmpl /var/www/cgi-bin/hyperestraier/estseek.tmpl
[root@Fedora ~]# cp /usr/share/hyperestraier/locale/ja/estseek.top /var/www/cgi-bin/hyperestraier/estseek.top
[root@Fedora ~]# cp /usr/share/hyperestraier/locale/ja/estseek.help /var/www/cgi-bin/hyperestraier/estseek.help

「Hyper Estraier」の設定

[root@Fedora ~]# vi /var/www/cgi-bin/hyperestraier/estseek.conf <= 設定ファイルの編集
indexname: casket
↓
indexname: /var/www/hyperestraier/crimson-snow <= インデックスを指定

replace: ^file:///home/mikio/public_html/{{!}}http://localhost/
↓
replace: ^file:///var/www/html/{{!}}http://www.crimson-snow.net/ <= 検索対象ディレクトリの置換

formtype: normal
↓
formtype: web <= 入力フォームの種類をWebサイト用にする

logfile:
↓
logfile: /var/log/hyperestraier.log <= 検索のログファイルを指定

「Hyper Estraier」の検索用ログを「Apache」の実行ユーザの権限で書き込み出来るように作成します。

[root@Fedora ~]# touch /var/log/hyperestraier.log <= ログファイルの作成
[root@Fedora ~]# chown apache /var/log/hyperestraier.log <= オーナの変更

ブラウザで
http://サーバのIPアドレス/cgi-bin/hyperestraier/estseek.cgi
とアクセスする。

サイト内に設置する場合

サイト内に検索用のFORMを設置する場合、設置したい場所に以下の内容を記述。

<FORM method="get" action="/cgi-bin/hyperestraier/estseek.cgi">
  <DIV>
    <INPUT type="text" name="phrase" value="" size="32" tabindex="1" />
    <INPUT type="submit" value="Search" tabindex="2" />
    <INPUT type="hidden" name="enc" value="UTF-8" />
  </DIV>
</FORM>
インデックスの自動作成&不要データ削除
[root@Fedora ~]# vi /root/hyperestraier.sh <= 文書の登録&インデックスの更新スクリプト作成
#!/bin/sh

ESTCMD='/usr/bin/estcmd'

$ESTCMD gather -cl -il ja -bc -sd -cm /var/www/hyperestraier/crimson-snow /var/www/html > /dev/null 2>&1
$ESTCMD create -attr @title str -attr @mdate seq -attr @size seq /var/www/hyperestraier/crimson-snow > /dev/null 2>&1


[root@Fedora ~]# chmod 744 /root/hyperestraier.sh <= 作成したスクリプトに実行権限付加

スクリプトの自動実行

[root@Fedora ~]# crontab -e <= 設定ファイルの編集
00 03 * * * /root/hyperestraier.sh <= 追加(毎日3:00にスクリプト実行)
10 03 * * 1 /usr/bin/estcmd purge -cl /var/www/hyperestraier/crimson-snow > /dev/null 2>&1 <= 追加(毎週月曜日に削除文書の反映)
30 03 1 * * /usr/bin/estcmd optimize /var/www/hyperestraier/crimson-snow > /dev/null 2>&1 <= 追加(毎月1回インデックスの最適化)
▲ページのトップへ