Forum: Ferret Using Highlight on Concatenated ActsAsFerret::SearchResults

Posted by JT Kimbell (studbucket)
on 2008-12-11 16:44
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 => "<strong>", :post_tag => "</strong>").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
Posted by JT Kimbell (studbucket)
on 2008-12-16 21:29
Just bumping this to see if someone could help me out.  Is there 
somewhere/someone else I should be asking?

Thanks,

JT
Posted by JT Kimbell (studbucket)
on 2009-01-20 05:08
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.