Commit b3bb13f2ab4b79d7bf4a1e3c7efd40e55e1b3eb4
1 parent
af84197c
Exists in
master
and in
18 other branches
Friendlier error message for bad mapping with partial matches - fixes #1127
Showing
3 changed files
with
7 additions
and
2 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/query.rb
... | ... | @@ -188,7 +188,7 @@ module Searchkick |
188 | 188 | ) |
189 | 189 | |
190 | 190 | raise UnsupportedVersionError, "This version of Searchkick requires Elasticsearch 5 or greater" |
191 | - elsif e.message.include?("[multi_match] analyzer [searchkick_search] not found") | |
191 | + elsif e.message =~ /analyzer \[searchkick_.+\] not found/ | |
192 | 192 | raise InvalidQueryError, "Bad mapping - run #{reindex_command}" |
193 | 193 | else |
194 | 194 | raise InvalidQueryError, e.message | ... | ... |
test/index_test.rb
... | ... | @@ -93,7 +93,8 @@ class IndexTest < Minitest::Test |
93 | 93 | def test_bad_mapping |
94 | 94 | Product.searchkick_index.delete |
95 | 95 | store_names ["Product A"] |
96 | - assert_raises(Searchkick::InvalidQueryError) { Product.search "test" } | |
96 | + error = assert_raises(Searchkick::InvalidQueryError) { Product.search "test" } | |
97 | + assert_equal "Bad mapping - run Product.reindex", error.message | |
97 | 98 | ensure |
98 | 99 | Product.reindex |
99 | 100 | end | ... | ... |