# Highlighting with find\_by\_contents

**URL:** <https://www.ruby-forum.com/t/highlighting-with-find-by-contents/74248>\
**Category:** Ferret\
**Created:** [November 2, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/highlighting-with-find-by-contents/74248 "2006-11-02T19:28:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukewarmtapioca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/67e7ee/32.png) [@lukewarmtapioca](https://www.ruby-forum.com/u/lukewarmtapioca)\
**Post date:** [November 2, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/highlighting-with-find-by-contents/74248/1 "2006-11-02T19:28:38Z")

</div>

I’m trying to highlight keyword snippets using the highlight method of  
the results returned from find\_by\_contents (the actual models), but  
always come up with an empty array. Any ideas what could be going wrong?

---

<div class="post-metadata">

**Author:** ![lukewarmtapioca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/67e7ee/32.png) [@lukewarmtapioca](https://www.ruby-forum.com/u/lukewarmtapioca)\
**Post date:** [November 7, 2006, 10:56am UTC](https://www.ruby-forum.com/t/highlighting-with-find-by-contents/74248/2 "2006-11-07T10:56:38Z")

</div>

Have you defined the field(s) as storable?

Link to FieldInfo class:  
[http://ferret.davebalmain.com/api/classes/Ferret/Index/FieldInfo.html](http://ferret.davebalmain.com/api/classes/Ferret/Index/FieldInfo.html)

You need to set up your fields with acts\_as\_ferret. This is how I have  
mine setup (still learning Ferret and AAF so may not be totally correct  
but highlighting works):

acts\_as\_ferret( :fields =\> {  
Â :name =\> {},  
Â :desc =\> {},  
Â :body =\> {:store =\> :yes},  
Â :role =\> {},  
})

This allows me to use the highlighting with the “body” field. The other  
ones still can’t highlight.

Curtis

----- Original Message -----  
From: Britt S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Date: Thursday, November 2, 2006 13:57  
Subject: [Ferret-talk] highlighting with find\_by\_contents  
To: removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![lukewarmtapioca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/67e7ee/32.png) [@lukewarmtapioca](https://www.ruby-forum.com/u/lukewarmtapioca)\
**Post date:** [November 7, 2006, 10:58am UTC](https://www.ruby-forum.com/t/highlighting-with-find-by-contents/74248/3 "2006-11-07T10:58:54Z")

</div>

Thanks Curtis and Jens. That worked great (after rebuilding index)!

Britt
