小编mar*_*-sn的帖子

太阳黑子突出没有出现

我已经浏览了github中的文档:http://github.com/outoftime/sunspot来找到突出显示的解决方案,但它似乎对我不起作用.

我的工作模型有这样的块(有意省略了一些字段):

  searchable do
    text :name

    string :name, :stored => true
    time :updated_at
    time :created_at
    time :expires_on

我有这个,它返回结果:

search = Sunspot.search(Job) do
  keywords 'Senior', :fields => "name", :highlight => true
end

=> 0, :fl=>"* score", :"hl.simple.pre"=>"@@@hl@@@", :qf=>"name_text", :rows=>30, :"hl.simple.post"=>"@@@endhl@@@", :hl=>"on", :q=>"senior", :fq=>["type:Job"], :defType=>"dismax"}>

并获得如此命中:

>> search.hits
=> [#, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #]

这是查询的结果,显示名称:

>> search.results.collect{|x| x.name}
= …

search ruby-on-rails sunspot hit-highlighting

9
推荐指数
1
解决办法
2369
查看次数

标签 统计

hit-highlighting ×1

ruby-on-rails ×1

search ×1

sunspot ×1