Commit ec4fedb26c1237d24adf5ea1e26b2f80a91d7e82

Authored by Andrew Kane
1 parent 1fec9ae0

Fixed bug with text values longer than 256 characters and _all field

1 -## 2.1.2 [unreleased] 1 +## 2.2.0 [unreleased]
2 2
  3 +- Fixed bug with text values longer than 256 characters and `_all` field - see [#850](https://github.com/ankane/searchkick/issues/850)
3 - Fixed issue with `_all` field in `searchable` 4 - Fixed issue with `_all` field in `searchable`
4 5
5 ## 2.1.1 6 ## 2.1.1
lib/searchkick/index_options.rb
@@ -25,7 +25,7 @@ module Searchkick @@ -25,7 +25,7 @@ module Searchkick
25 } 25 }
26 end 26 end
27 27
28 - keyword_mapping[:ignore_above] = (options[:ignore_above] || 256) unless below22 28 + keyword_mapping[:ignore_above] = (options[:ignore_above] || 30000) unless below22
29 29
30 settings = { 30 settings = {
31 analysis: { 31 analysis: {
test/index_test.rb
1 require_relative "test_helper" 1 require_relative "test_helper"
2 2
3 class IndexTest < Minitest::Test 3 class IndexTest < Minitest::Test
  4 + def setup
  5 + super
  6 + Region.destroy_all
  7 + end
  8 +
4 def test_clean_indices 9 def test_clean_indices
5 old_index = Searchkick::Index.new("products_test_20130801000000000") 10 old_index = Searchkick::Index.new("products_test_20130801000000000")
6 different_index = Searchkick::Index.new("items_test_20130801000000000") 11 different_index = Searchkick::Index.new("items_test_20130801000000000")
@@ -127,8 +132,20 @@ class IndexTest &lt; Minitest::Test @@ -127,8 +132,20 @@ class IndexTest &lt; Minitest::Test
127 132
128 def test_large_value 133 def test_large_value
129 skip if nobrainer? 134 skip if nobrainer?
  135 + large_value = 1000.times.map { "hello" }.join(" ")
  136 + store [{name: "Product A", text: large_value}], Region
  137 + assert_search "product", ["Product A"], {}, Region
  138 + assert_search "hello", ["Product A"], {fields: [:name, :text]}, Region
  139 + assert_search "hello", ["Product A"], {}, Region
  140 + end
  141 +
  142 + def test_very_large_value
  143 + skip if nobrainer?
130 large_value = 10000.times.map { "hello" }.join(" ") 144 large_value = 10000.times.map { "hello" }.join(" ")
131 - store [{name: "Product A", alt_description: large_value}]  
132 - assert_search "product", ["Product A"] 145 + store [{name: "Product A", text: large_value}], Region
  146 + assert_search "product", ["Product A"], {}, Region
  147 + assert_search "hello", ["Product A"], {fields: [:name, :text]}, Region
  148 + # values that exceed ignore_above are not included in _all field :(
  149 + # assert_search "hello", ["Product A"], {}, Region
133 end 150 end
134 end 151 end