Using Highlight on Concatenated ActsAsFerret::SearchResults


#1

Hi,

This is my first attempt at trying to use aaf’s highlight function, and
I am having a getting it to return anything. First I’ll give some
background, then show you my problem.

In my model, I have the content field stored.

acts_as_ferret :fields => { :title => {:store => :no}, :content =>
{:store => :yes}}

In my controller, I have a list of queries that I have created (A causes
B, B is caused by A, A may cause B, etc) and when a link is selected all
of those ‘synonymous’ queries are executed and their results are
concatenated together. Some code for that is below:

@results = []
@queries = #List of unique queries from database
for @q in @queries
@results.concat(Result.find_by_contents(CGI::unescape(@q.exactquery),
:lazy => :true))
end

So, you see that I now have an array containing individual
ActsAsFerret::SearchResult objects. When one of the results is
selected, I grab that result from the array and attempt to display it
with the query highlighted in my view. Here is that code:

<%= @result.highlight(@query, :field => :content, :num_excerpts => 1,
:pre_tag => “”, :post_tag => “”).to_s %>

If I put <%= @result.content %> in the view, the content is posted just
fine, but if I have the above code in the view, nothing is displayed on
the page.

Am I doing something wrong with highlighting? Am I losing something
when concatenating the results into an array?

Your help is much appreciated.

JT


#2

Just bumping this to see if someone could help me out. Is there
somewhere/someone else I should be asking?

Thanks,

JT


#3

One last bump, I really, really, really would appreciate some help on
this.

If you can’t help me here, is there somewhere else I can look for help?

Thanks,

JT