From a4cbb6140145c12fc1ee38f9ac219489982a149b Mon Sep 17 00:00:00 2001 From: David Runger Date: Wed, 22 Nov 2023 16:35:16 -0600 Subject: [PATCH] Don't search misspellings for an errored query (#1655) --- lib/searchkick/query.rb | 2 +- test/multi_search_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index 96f6ae03..5defc303 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -191,7 +191,7 @@ def handle_response(response) end def retry_misspellings?(response) - @misspellings_below && Results.new(searchkick_klass, response).total_count < @misspellings_below + @misspellings_below && response["error"].nil? && Results.new(searchkick_klass, response).total_count < @misspellings_below end private diff --git a/test/multi_search_test.rb b/test/multi_search_test.rb index 96c4b023..88a9b584 100644 --- a/test/multi_search_test.rb +++ b/test/multi_search_test.rb @@ -33,6 +33,12 @@ def test_misspellings_below_unmet assert_equal ["abc", "abd"], products.map(&:name) end + def test_misspellings_below_with_errored_query + products = Product.search("abc", order: [:bad_field], misspellings: {below: 1}) + Searchkick.multi_search([products]) + assert products.error + end + def test_query_error products = Product.search("*", order: {bad_column: :asc}) Searchkick.multi_search([products])