# Need help getting ahold of highlight property when using Tire gem

**URL:** <https://discuss.elastic.co/t/need-help-getting-ahold-of-highlight-property-when-using-tire-gem/9004>\
**Category:** Elasticsearch\
**Created:** [September 12, 2012, 3:49pm UTC](https://discuss.elastic.co/t/need-help-getting-ahold-of-highlight-property-when-using-tire-gem/9004 "2012-09-12T15:49:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meltemi](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@Meltemi](https://discuss.elastic.co/u/Meltemi)\
**Post date:** [September 12, 2012, 3:49pm UTC](https://discuss.elastic.co/t/need-help-getting-ahold-of-highlight-property-when-using-tire-gem/9004/1 "2012-09-12T15:49:30Z")

</div>

I'm having a hard time getting ahold of the highlight property in my Rails  
app. I know the highlight is being return because it's present in curl  
results that I get from `raise to_curl`.

Simple _controller_:

def index  
@reports = Report.search(params)  
end

Simple _model_:

def self.search(params)  
tire.search do  
query { string params[:query] } if params[:query].present?  
highlight :attachment  
# raise to\_curl  
end  
end

Simple \*view \*(haml):

- @reports.each do |report|
# - @reports._results_.each do |report| # \<== doesn't work either

  - if report.respond\_to?(:highlight)  
= raw report.highlight.attachment.first.to\_s
  - else  
= "broken!" # \<=== only ever see this  
...

Abbreviated curl response from raise to\_curl in model (FWIW):  
[https://gist.github.com/3707560](https://gist.github.com/3707560)

What am I missing?!? What's the proper way of getting ahold of the  
'highlight' string associated with each record? I know I'm overlooking the  
painfully obvious. Thanks!

--

---

<div class="post-metadata">

**Author:** ![Meltemi](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@Meltemi](https://discuss.elastic.co/u/Meltemi)\
**Post date:** [September 12, 2012, 4:17pm UTC](https://discuss.elastic.co/t/need-help-getting-ahold-of-highlight-property-when-using-tire-gem/9004/2 "2012-09-12T16:17:41Z")

</div>

In my troubleshooting I think I may have made this more difficult than it  
needed to be by adding faulty 'responds\_to?' check.

= raw report.highlight.attachment.first.to\_s

seems to work. Still love to hear/see if someone has a better way.

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:13am UTC](https://discuss.elastic.co/t/need-help-getting-ahold-of-highlight-property-when-using-tire-gem/9004/3 "2017-07-06T03:13:01Z")

</div>

Closed on July 6, 2017, 3:13am UTC


