カスタム検索
このエントリーをはてなブックマークに追加
tomo.gif (1144 ツバツイツト)line.gif (927 ツバツイツト)To previous pageTo home pageMailing to me

Nanazu2.0.4(全文検索)を動かしてみる

(RedHat Linux)

Modified: 23 Jul 2000

TurboLinux4.0 では、glibc や perl のアップグレードが必要で、インストールしてもいたちごっこ状態であきらめましたが、RedHatLinux6.2 ではなんなくインストールできました。


Namazuと関連ファイルのダウンロード
Namazuを設定する
Namazuを動かしてみる
Namazuの運用


 Namazuと関連ファイルのダウンロード

Namazuのダウンロード

以下から、namazu と関連のファイルをダウンロードします。

http://www.namazu.org/

以下の、6つのファイルをダウンロードします。


kakasi関連のインストール

# rpm -ivh kakasi-2_3_2-1_i386.rpm
kakasi     ##################################################
# rpm -ivh kakasi-dict-2_3_2-1_i386.rpm
kakasi-dict    ##################################################
#


perl関連のインストール

http://www.namazu.org/

上記から、以下の3つをダウンロードします。

をダウンロードします。

rpmを展開します。

# rpm -ivh perl-File-MMagic-1_06-1_i386.rpm
perl-File-MMagic    ##################################################
# rpm -ivh perl-NKF-1_71-1_i386.rpm
perl-NKF     ##################################################
# rpm -ivh perl-Text-Kakasi-1_04-1_i386.rpm
perl-Text-Kakasi     ##################################################
#


Namazuのインストール

”namazu-2_0_4-1_i386.rpm”をダウンロードして、rpmを展開します。

# rpm -ivh namazu-2_0_4-1_i386.rpm
namazu   ##################################################
#

 Namazuを設定する

インデックスファイルを作ってみる

まず、日本語の文書が扱えるように環境変数を設定します。

# export LANG=ja_JP.ujis

次に、以下の手順で、インデックスファイルを作ってみます。

まず、/tmp に、indexses というディレクトリを作ります。

# mkdir  /tmp/indexes

インデックスの作成をします。

# /usr/bin/mknmz -O /tmp/indexes --allow=".*\.html" /usr/local/apache/htdocs
    :
#


namazu.cgi の移動

namazu.cgi を、apache のドキュメントディレクトリに移動します。

# cp /home/httpd/cgi-bin/namazu.cgi /usr/local/apache/cgi-bin/
#


.namazurc の作成

.namazurc の雛型をコピー

# cp /etc/namazu/namazurc /usr/local/apache/cgi-bin/.namazurc
#

atten.gif (960 ツバツイツト) ".namazurc"の先頭に、"."が付いているで注意


.namazurc の編集

赤いところを追加します。

# This is a Namazu configuration file for namazu or namazu.cgi.
#
# Originally, this file is named 'namazurc-sample'. so you should
# copy this to 'namazurc' to make the file effective.
#
# Each item is must be separated by one or more SPACE or TAB characters.
# You can use a double-quoted string for represanting a string which
# contains SPACE or TAB characters like "foo bar baz".


##
## Index: Specify the default directory.
##
#Index /usr/local/var/namazu/index
Index /tmp/indexes

##
## Template: Set the template directory containing
## NMZ.{head,foot,body,tips,result} files.
##
#Template /usr/local/var/namazu/index
Template /tmp/indexes

##
## Replace: Replace TARGET with REPLACEMENT in URIs in search
## results.
##
## TARGET is specified by perl-like regular expressions.
## You can caputure sub-strings in TARGET by surrounding them
## with `(' and `)'and use them later as backreferences by
## \1, \2, \3,... \9.
##
## To use meta characters literally such as `*', `+', `?', `|',
## `[', `]', `{', `}', `(', `)', escape them with `\'.
##
## e.g.,
##
## Replace /home/foo/public_html/ http://www.foobar.jp/~foo/
## Replace /home/(.*)/public_html/ http://www.foobar.jp/\1/
## Replace /C\|/foo/ http://www.foobar.jp/
##
## If you do not want to do the processing on command line use,
## run namazu with -U option.
##
#Replace /home/foo/public_html/ http://www.foo.bar.jp/~foo/
Replace /usr/local/apache/htdocs/ http://192.168.0.6/

##
## Logging: Set OFF to turn off keyword logging to NMZ.slog.
## Default is ON.
##
#Logging off


##
## Lang: Set the locale code such as `ja_JP.eucJP', `ja_JP.SJIS',
## `de', etc. This directive works only if the environment
## variable LANG is not set because the directive is mainly
## intended for CGI use. On the shell, You can set
## environemtnt variable LANG instead of using the directive.
##
## If you set `de' to it, namazu.cgi use
## NMZ.(head|foot|body|tips|results).de for displaying results
## and use a proper message catalog for `de'.
##
#Lang ja
Lang ja

##
## Scoring: Set the scoring method "tfidf" or "simple".
##
#Scoring tfidf


##
## EmphasisTags: Set the pair of html elements which is used in
## keyword emphasizing for search results.
##
#EmphasisTags "<strong class=\"keyword\">" "</strong>"


 Namazuを動かしてみる

Netscapeで表示してみる

URLとして、以下のように入れます。

http://192.168.0.6/cgi-bin/namazu.cgi

"192.168.0.6"は、apacheやnamazuが動作しているPCのIPアドレスです。
すると、以下のように表示されます。

nmz1.gif (24286 ツバツイツト)


 Namazuの運用

Namazuのテンプレートのカスタマイズ

/tmp/indexes内のファイル 使われる場面
NMZ.head.ja 検索結果画面のヘッダー部分のテンプレート
NMZ.foot.ja 検索結果画面のフッター部分のテンプレート
NMZ.result.normal.ja 検索結果を一件表示(標準)するテンプレート
NMZ.result.short.ja 検索結果を一件表示(簡潔)するテンプレート
NMZ.body.ja 検索式が空白のとき表示されるテンプレート
NMZ.tips.ja 検索結果、表示するものがなかったとき表示されるテンプレート

インデックスの定期的作成

”cron”を使って、定期的にインデックスを作りかえるようにしていると便利である。


To previous pageTo home pageMailing to meJump to Top of pagetomo.gif (1144 ツバツイツト)
カスタム検索



このエントリーをはてなブックマークに追加