Skip to content

Commit

Permalink
Don't search misspellings for an errored query (#1655)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrunger-cl authored Nov 22, 2023
1 parent a682677 commit a4cbb61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/searchkick/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/multi_search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit a4cbb61

Please sign in to comment.