# Using Highlight on Concatenated ActsAsFerret::SearchResults

**URL:** <https://www.ruby-forum.com/t/using-highlight-on-concatenated-actsasferret-searchresults/155417>\
**Category:** Ferret\
**Created:** [December 11, 2008, 4:44pm UTC](https://www.ruby-forum.com/t/using-highlight-on-concatenated-actsasferret-searchresults/155417 "2008-12-11T16:44:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![studbucket](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@studbucket](https://www.ruby-forum.com/u/studbucket)\
**Post date:** [December 11, 2008, 4:44pm UTC](https://www.ruby-forum.com/t/using-highlight-on-concatenated-actsasferret-searchresults/155417/1 "2008-12-11T16:44:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![studbucket](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@studbucket](https://www.ruby-forum.com/u/studbucket)\
**Post date:** [December 16, 2008, 9:29pm UTC](https://www.ruby-forum.com/t/using-highlight-on-concatenated-actsasferret-searchresults/155417/2 "2008-12-16T21:29:35Z")

</div>

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

Thanks,

JT

---

<div class="post-metadata">

**Author:** ![studbucket](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@studbucket](https://www.ruby-forum.com/u/studbucket)\
**Post date:** [January 20, 2009, 5:08am UTC](https://www.ruby-forum.com/t/using-highlight-on-concatenated-actsasferret-searchresults/155417/3 "2009-01-20T05:08:57Z")

</div>

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
