Commit db0816c0a8c477efcc72658435a38db8b7f17b00

Authored by Andrew
1 parent 783671d7

Fixed highlighting for ES5

lib/searchkick/query.rb
@@ -659,7 +659,7 @@ module Searchkick @@ -659,7 +659,7 @@ module Searchkick
659 def set_highlights(payload, fields) 659 def set_highlights(payload, fields)
660 payload[:highlight] = { 660 payload[:highlight] = {
661 fields: Hash[fields.map { |f| [f, {}] }], 661 fields: Hash[fields.map { |f| [f, {}] }],
662 - fragment_size: 0 662 + fragment_size: below60? ? 30000 : 0
663 } 663 }
664 664
665 if options[:highlight].is_a?(Hash) 665 if options[:highlight].is_a?(Hash)
@@ -960,6 +960,10 @@ module Searchkick @@ -960,6 +960,10 @@ module Searchkick
960 end 960 end
961 end 961 end
962 962
  963 + def below60?
  964 + Searchkick.server_below?("6.0.0-alpha1")
  965 + end
  966 +
963 def below61? 967 def below61?
964 Searchkick.server_below?("6.1.0-alpha1") 968 Searchkick.server_below?("6.1.0-alpha1")
965 end 969 end
test/highlight_test.rb
@@ -17,7 +17,7 @@ class HighlightTest < Minitest::Test @@ -17,7 +17,7 @@ class HighlightTest < Minitest::Test
17 end 17 end
18 18
19 def test_very_long 19 def test_very_long
20 - store_names ["Two Door Cinema Club " * 100] 20 + store_names [("Two Door Cinema Club " * 100).strip]
21 assert_equal ("Two Door <em>Cinema</em> Club " * 100).strip, Product.search("cinema", highlight: true).highlights.first[:name] 21 assert_equal ("Two Door <em>Cinema</em> Club " * 100).strip, Product.search("cinema", highlight: true).highlights.first[:name]
22 end 22 end
23 23