您的位置:首页 > 其它

vim配置使用总结

2013-08-26 15:20 459 查看
在配置environment中加入
Ultrasphinx::Search.excerpting_options =
HashWithIndifferentAccess.new({
:before_match => '<span style="font-weight:bold;color:red">',
:after_match => '</span>',
:chunk_separator => "...",
:limit => 256,
#s:around => 2, # This doesn't seem to work.
:content_methods => [['title'], ['body', 'description', 'content']]

})

在搜索的article.rb中修改搜索方法
def self.my_search(search)
# find(:all, :conditions => ['body LIKE ? OR title LIKE ? OR description LIKE ?', "%#{search}%","%#{search}%","%#{search}%"])
my_search_result = Ultrasphinx::Search.new(:query=>search)
my_search_result.run
my_search_result.excerpt
end
最后返回的是excerpt

测试
a=Ultrasphinx::Search.new(:query=>'new')
a.run
a.excerpt
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: