[ Main Page ]

検索 tips

全文検索の設定の仕方。

namazuを使う

Installing namazu

ディストリビューションによってデフォルトをキャッシュの位置が違うようです。Vine Linuxの場合、

./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \
--localstatedir=/var --libexecdir=/home/httpd/cgi-bin
    

のようにするとよいでしょう。時々バグが見つかるので、注意が必要です。

Making index

インデックスを作るcronを日に一回走らせます。
#!/bin/sh
# /home/httpd/indexに/usr/share/namazu/templateを
# テンプレートとして/home/httpd/htmlの内容のインデックスを作成
mknmz -q -c -O /home/httpd/index --exclude="(squirrelmail|cdrom|tiki)" \
/home/httpd/html/ -T /usr/share/namazu/template
# インデックス更新だけでは使われない部分がたまるので
# ガベージコレクションを実行する
gcnmz -q /home/httpd/index
    

この時に注意するのは、対象となるディレクトリと、テンプレートのディレクトリです。 対象となるディレクトリは、文字通り、検索の対象とするディレクトリです。 テンプレートのディレクトリは、検索時に

Namazu による全文検索システム
現在、 2,276 の文書がインデックス化され、 36,146 個のキーワードが登録されています。
インデックスの最終更新日: 2005-01-21 
    

のように表示される部分などのhtmlファイルを含むディレクトリです。通常、 NMZ.body.ja NMZ.foot.ja NMZ.head.ja NMZ.result.normal.ja NMZ.result.short.ja NMZ.tips.jaのセットを言語の種類だけ持ちます。 命名規則は、NMZ.(種類).(言語名)です。.(言語名)の部分がないものは デフォルト(英語)ですが、後述する.namazurcでデフォルトの言語を変えることもできます。 例えば、NMZ.headの一部は以下のようになっています。

...
</head>
<body lang="en">
<h1>Namazu: a Full-Text Search Engine</h1>
<p>
This index contains <!-- FILE --> 0 <!-- FILE --> documents and
<!-- KEY --> 0 <!-- KEY --> keywords. 
</p>
<p>
<strong>Last modified: <!-- DATE --> date <!-- DATE --></strong>
</p>
...
    
インデックス作成時に、<!-- FILE --> 0 <!-- FILE -->などの部分は実際の 文字列で置き換えられてインデックス出力ディレクトリに
...
</head>
<body lang="en">
<h1>Namazu: a Full-Text Search Engine</h1>
<p>
This index contains <!-- FILE --> 2,276 <!-- FILE --> documents and
<!-- KEY --> 36,146 <!-- KEY --> keywords. 
</p>
<p>
<strong>Last modified: <!-- DATE --> 2005-01-21 <!-- DATE --></strong>
</p>
...
    

といった内容で出力されます。

cgi-binの設定

cgi-binでの設定では、.namazurcを以下のように項目を設定します。

...
Index         /home/httpd/index
Template      /home/httpd/index
...
    

HTMLページでの検索部分は、例えば、namazu.cgiがhttp://localhost/cgi-bin/namazu.cgi にあるとして、.namazurcを上の様に設定して、namazu.cgiとおなじディレクトリに置き、

<form method="GET" action="/cgi-bin/namazu.cgi">
<strong>ここの文書を検索</strong>
<INPUT TYPE="TEXT" NAME="key" SIZE="20" value="">
<INPUT TYPE="SUBMIT" NAME="submit"VALUE="Go">
<INPUT TYPE="HIDDEN" NAME="whence"VALUE="0">
</FORM>
    

のようなコードを書けば良いでしょう。

> > My Commodore 64 is suffering from slowness and insufficiency of memory;
> > and its display device is grievously short of pixels.  Can anyone help?
>
> I can give you 64K of memory to make it a Commodore 128, it will be just
> like brand new. I'll throw in a disk drive so you can dump the
> cassettes, they are obsolete these days.

Leave your Commodore alone, this platform does not allow good scaling, even 
doubling RAM amount... I think it's good time to upgrade to XT. You can even 
install another 8088 instead of 8087 co-processor. Dual-CPU system would 
allow greater throughput in multiuser enviroment. Yes, I know it demands 
bigger initial investment, but the ROI is guaranteed in no more than 2
years.	

	Omer Zak, Baruch Even and Alexey Maslennikov on
	discussions@hamakor.org.il

    -- Alexey Maslennikov
    -- Post to the Hamakor Discussions Mailing List ( http://mirror.hamakor.org.il/archives/discussions/05-2005/1500.html )

  <rindolf>  Is gstein the person to blame for the anti-Perl FUD on
             http://viewcvs.sf.net/?
  <sussman>  yes.
 <cmpilato>  likely. . . .
  <ghudson>  Subversion used to be this amazing nest of anti-perl people.
             That's calmed down a bit... largely because Greg Stein has
             been distracted. :)
  <rindolf>  I personally am a Perl guy who despises Python, but can still
             tolerate the Subversion tests because they are actually shell
             scripts in disguise.
          *  jackr thinks there are other Python-loving Perl haters around
             Python

    -- #svn, Freenode


Powered by UNIX fortune(6)
[ Main Page ]