社区全文检索引擎Hyper Estraier 学习笔记[4]

如何搭建一个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/目录下:

  1. estcmd create man_docs_db
  2. 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的配置:

  1. <directory /home/y/www/search_tool/>
  2. Options +ExecCGI
  3. addHandler cgi-script cgi pl
  4. </directory>

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

  1. indexname: man_docs_db
  2. tmplfile: estseek.tmpl
  3. topfile: estseek.top
  4. helpfile: estseek.help
  5. lockindex: true
  6. pseudoindex:
  7. replace: ^file:///home/y/www/search_doc/{{!}}/search_doc/
  8. replace: /index\.html?${{!}}/
  9. showlreal: false
  10. deftitle: Hyper Estraier: a full-text search system for communities
  11. formtype: normal
  12. perpage: 10 100 10
  13. attrselect: false
  14. #genrecheck: private{{!}}private
  15. #genrecheck: business{{!}}business
  16. #genrecheck: misc{{!}}miscellaneous
  17. attrwidth: 80
  18. showscore: true
  19. extattr: author|Author
  20. extattr: from|From
  21. extattr: to|To
  22. extattr: cc|Cc
  23. extattr: date|Date
  24. snipwwidth: 480
  25. sniphwidth: 96
  26. snipawidth: 96
  27. condgstep: 2
  28. dotfidf: true
  29. scancheck: 3
  30. phraseform: 2
  31. dispproxy:
  32. candetail: true
  33. candir: false
  34. auxmin: 32
  35. smlrvnum: 32
  36. smlrtune: 16 1024 4096
  37. clipview: 2
  38. clipweight: none
  39. relkeynum: 0
  40. spcache:
  41. wildmax: 256
  42. qxpndcmd:
  43. logfile:
  44. 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,并给一个表单:

  1. <form method="GET" action="estseek.cgi">
  2. <div>
  3. <input type="text" name="phrase" value="" size="32" />
  4. <input type="submit" value="Search" />
  5. <input type="hidden" name="enc" value="UTF-8" />
  6. </div>
  7. </form>

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


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

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

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


当前日志信息