Method: SearchFlip::Highlightable#highlight
- Defined in:
- lib/search_flip/highlightable.rb
#highlight(fields, options = {}) ⇒ SearchFlip::Criteria
Adds highlighting of the given fields to the request.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/search_flip/highlightable.rb', line 32 def highlight(fields, = {}) fresh.tap do |criteria| criteria.highlight_values = (criteria.highlight_values || {}).merge() hash = case fields when Hash fields when Array fields.each_with_object({}) { |field, h| h[field] = {} } else { fields => {} } end criteria.highlight_values[:fields] = (criteria.highlight_values[:fields] || {}).merge(hash) end end |