»
S
I
D
E
B
A
R
«
社区全文检索引擎Hyper Estraier 学习笔记[4]
July 12th, 2008 by 一米六二

如何搭建一个Web界面的搜索界面
现在我的硬盘上有Linux帮助,php中文文档,mysql文档,C函数手册等文档等,它们一共有500M.
我需要一个索引工具。但是明显在命令行不是太方便。因为这些文档全是HTML格式的,我需要用浏览器来打开它们查看。
我决定在本机架设一个apache,利用hyperestraier来进行索引,提供像Google/baidu那样的web界面。
这是我的操作步骤:
1 准备目录:
我在www目录下新建了两个目录,search/tool和search/search_doc目录,将属主改为apache(这是我的apache运行的用户名).
search/tool/用来放置hyperestraier的程序和索引数据库,search_doc/下放置原始的各种帮助文档。
2.索引帮助文档:
在search/tool/目录下:

estcmd create man_docs_db
find ../search_doc/ -name “*.html” -type f|estcmd gather -cl -fm -cm ./man_docs_db -

然后Hyperestraier就哗啦哗啦地索引这500多M的文要资料。很快就索引完了。
3.进行CGI和estseek.cgi的相关设置。
我们将编译hyperestraier目录下产生的estseek.*复制到search_tool目录下,并修改apache的关于CGI的配置:


Options +ExecCGI
addHandler cgi-script cgi pl


现在search_tool目录下的estseek.cgi能被执行了.当然你得执行chmod a+x estseek.cgi或是chmod 0755 estseek.cgi给这个文件加上执行权屯限。
接着编辑search_tool目录下的estseek.conf文件:

indexname: man_docs_db
tmplfile: estseek.tmpl
topfile: estseek.top
helpfile: estseek.help
lockindex: true
pseudoindex:
replace: ^file:///home/y/www/search_doc/{{!}}/search_doc/
replace: /index\.html?${{!}}/
showlreal: false
deftitle: Hyper Estraier: a full-text search system for communities
formtype: normal
perpage: 10 100 10
attrselect: false
#genrecheck: private{{!}}private
#genrecheck: business{{!}}business
#genrecheck: misc{{!}}miscellaneous
attrwidth: 80
showscore: true
extattr: author|Author
extattr: from|From
extattr: to|To
extattr: cc|Cc
extattr: date|Date
snipwwidth: 480
sniphwidth: 96
snipawidth: 96
condgstep: 2
dotfidf: true
scancheck: 3
phraseform: 2
dispproxy:
candetail: true
candir: false
auxmin: 32
smlrvnum: 32
smlrtune: 16 1024 4096
clipview: 2
clipweight: none
relkeynum: 0
spcache:
wildmax: 256
qxpndcmd:
logfile:
logformat: {time}\t{REMOTE_ADDR}:{REMOTE_PORT}\t{cond}\t{hnum}\n


这里主要要修改indexname和replace.
说明:
indexname是你前面用estcmd create命令创建的索引数据库的名字.
replace可以多行,能对搜索结果中显示的文件路径做一个正则替换。因为索引入库的URL是file:///home/***类似
的路径,在web中显示出来没法访问。
好的,现在在search_tool/目录创建一个首页index.html,并给一个表单:


现在就可以通过http://localhost/search_tool/来搜索你的帮助文档了。


后记:
但是,很快我发现几个问题:
1:Hyperestraier在处理gb2312的文档时,似乎有时侦测文档的编码类型会失败。搜索的时候对应的结果没有。
2.在显示搜索结果的摘要时,没有过滤HTML标签。这是我问题:我在检索的时候应该用的是:

find ../search_doc/ -name “*.html” -type f|estcmd gather -cl -fm -cm -fh ./man_docs_db -

这才能按照html来解析,否则是按mime来解析的。
3.搜两个词时,我期望的是同时包含其中任何一个词的网页都能出来,但是Hyperestraier就只搜同时包含这两个词的网页,所以搜长点的词经常结果为空。
4.对于有些词,比如中文的”的”,英文的”the”,没有进行忽略。当然这对目前的应用来说不是太大的问题。
但是无论如何,前三个问题,迫切需要解决。下一次就来抓一个出来处理掉。


Leave a Reply

»  Substance: WordPress   »  Style: Ahren Ahimsa
29015 页面访问次数, 578 今天
11220 访问数, 167 今天
FireStats icon 由FireStats提供支持