Commit dd1d3724ce0bd2bf2076180caf2bdef548981475
1 parent
b5bfe4c5
Exists in
master
and in
18 other branches
Check for hit highlight as well [skip ci]
Showing
1 changed file
with
2 additions
and
2 deletions
Show diff stats
lib/searchkick/results.rb
... | ... | @@ -31,7 +31,7 @@ module Searchkick |
31 | 31 | hits.map do |hit| |
32 | 32 | result = results[hit["_type"]][hit["_id"].to_s] |
33 | 33 | if result && !(options[:load].is_a?(Hash) && options[:load][:dumpable]) |
34 | - if options[:highlight] && !result.respond_to?(:search_highlights) | |
34 | + if (hit["highlight"] || options[:highlight]) && !result.respond_to?(:search_highlights) | |
35 | 35 | highlights = hit_highlights(hit) |
36 | 36 | result.define_singleton_method(:search_highlights) do |
37 | 37 | highlights |
... | ... | @@ -57,7 +57,7 @@ module Searchkick |
57 | 57 | hit |
58 | 58 | end |
59 | 59 | |
60 | - if @options[:highlight] | |
60 | + if hit["highlight"] || options[:highlight] | |
61 | 61 | highlight = Hash[hit["highlight"].to_a.map { |k, v| [base_field(k), v.first] }] |
62 | 62 | options[:highlighted_fields].map { |k| base_field(k) }.each do |k| |
63 | 63 | result["highlighted_#{k}"] ||= (highlight[k] || result[k]) | ... | ... |