diff --git a/CHANGELOG.md b/CHANGELOG.md index dcef878..ea70a0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -## 2.1.2 [unreleased] +## 2.2.0 [unreleased] +- Fixed bug with text values longer than 256 characters and `_all` field - see [#850](https://github.com/ankane/searchkick/issues/850) - Fixed issue with `_all` field in `searchable` ## 2.1.1 diff --git a/lib/searchkick/index_options.rb b/lib/searchkick/index_options.rb index 629ed8b..3ff76f0 100644 --- a/lib/searchkick/index_options.rb +++ b/lib/searchkick/index_options.rb @@ -25,7 +25,7 @@ module Searchkick } end - keyword_mapping[:ignore_above] = (options[:ignore_above] || 256) unless below22 + keyword_mapping[:ignore_above] = (options[:ignore_above] || 30000) unless below22 settings = { analysis: { diff --git a/test/index_test.rb b/test/index_test.rb index b7eff11..46aef59 100644 --- a/test/index_test.rb +++ b/test/index_test.rb @@ -1,6 +1,11 @@ require_relative "test_helper" class IndexTest < Minitest::Test + def setup + super + Region.destroy_all + end + def test_clean_indices old_index = Searchkick::Index.new("products_test_20130801000000000") different_index = Searchkick::Index.new("items_test_20130801000000000") @@ -127,8 +132,20 @@ class IndexTest < Minitest::Test def test_large_value skip if nobrainer? + large_value = 1000.times.map { "hello" }.join(" ") + store [{name: "Product A", text: large_value}], Region + assert_search "product", ["Product A"], {}, Region + assert_search "hello", ["Product A"], {fields: [:name, :text]}, Region + assert_search "hello", ["Product A"], {}, Region + end + + def test_very_large_value + skip if nobrainer? large_value = 10000.times.map { "hello" }.join(" ") - store [{name: "Product A", alt_description: large_value}] - assert_search "product", ["Product A"] + store [{name: "Product A", text: large_value}], Region + assert_search "product", ["Product A"], {}, Region + assert_search "hello", ["Product A"], {fields: [:name, :text]}, Region + # values that exceed ignore_above are not included in _all field :( + # assert_search "hello", ["Product A"], {}, Region end end -- libgit2 0.21.0