Hyper Estraier与acts_as_searchable实践

东郭子默
2023-12-01
acts_as_searchable是一个Rails插件,它依赖于Hyper Estraier这个独立的搜索引擎所提供的索引和搜索服务

1,安装Hyper Estraier
去[url]http://hyperestraier.sourceforge.net/win/[/url]下载Binary Packages for Windows,将hyperestraier-1.4.10-win32.zip解压到C:\hyperestraier,将C:\hyperestraier加入到系统环境变量PATH中去

2,启动Hyper Estraier
[code]
C:\est> estmaster init .
C:\est> estmaster start .
[/code]
打开浏览器,访问[url]http://localhost:1978/[/url],默认用户名和密码均为admin,进入Mananage Nodes,添加一个name和label均为development的node

3,安装acts_as_searchable
[code]
ruby script/plugin install svn://poocs.net/plugins/trunk/acts_as_searchable
[/code]

4,修改Model
[code]
class Book < ActiveRecord::Base
acts_as_searchable :searchable_fields => [:title]
end
[/code]

5,可以search啦!
[code]
Book.fulltext_search(@title)
[/code]

Hyper Estraier很强大,索引和搜索速度快,中文支持良好,acts_as_searchable加了一些钩子来让ActiveRecord Model实时增量更新索引,它们的组合是不错的选择!
 类似资料: