I've gone through the docs in github: http://github.com/outoftime/sunspot to find solutions for highlighting, but it doesn't seem to work for me.
My Job model has something like this block (omitted some fields on purpose):
searchable do text :name string :name, :stored => true time :updated_at time :created_at time :expires_on
I have this, which returns results:
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"}>
and getting the hits as such:
>> search.hits => [#, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #]
and here were the results of the query, displaying the name:
>> search.results.collect{|x| x.name} => ["Senior Associate, Executive Membership", "Senior International Costing Analyst", "Senior Process Engineer", "Deputy Senior Process Manager", "Senior Engineer (Rotating Equipment)", "Senior Technical Expert, Indonesia", "Senior Combustion Engineer", "Senior Project Engineer/ Engineering Manager", "Senior Substructure Design Specialist, Bangladesh", "Senior Supervision Engineer (Superstructure), Bangladesh", "Senior Program and Strategy Development Advisor- Consultant", "Senior Associate (Natural Resource Management Specialist)", "Senior Manager (Agriculture Market Development, Afghanistan)", "Senior Material Engineer (Main Bridge), Bangladesh", "Senior Resident Engineer (Main Bridge), Bangladesh", "Senior Resident Engineer (Main Bridge), Bangladesh", "Senior Material Engineer (Main Bridge), Bangladesh"]
and here comes my problem.. when I get the highlights, none were returned:
>> search.hits.collect{|x| x.highlight(:name)} => [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
and even this, doesn't return highlight hits:
>> search.hits.collect{|x| x.highlights} => [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
Am I missing other flags or arguments?