From 0d6bdfe3c89768b39daea1773321c0ea8ef41560 Mon Sep 17 00:00:00 2001 From: Caio Almeida <117518+caiosba@users.noreply.github.com> Date: Mon, 16 Dec 2024 10:47:57 -0300 Subject: [PATCH] Handle single quote when searching by keyword. (#2158) Similarly to other characters, add single quotes to the list of characters to handle when searching by keyword. Fixes: CV2-5808. --- lib/check_search.rb | 2 +- test/lib/check_search_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/check_search.rb b/lib/check_search.rb index 17e64282d..509570c82 100644 --- a/lib/check_search.rb +++ b/lib/check_search.rb @@ -55,7 +55,7 @@ def adjust_keyword_filter unless @options['keyword'].blank? # This regex removes all characters except letters, numbers, hashtag, search operators, emojis and whitespace # in any language - stripping out special characters can improve match results - @options['keyword'].gsub!(/[^[:word:]\s#~+\-|()"\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1F1E6}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/, ' ') + @options['keyword'].gsub!(/[^[:word:]\s#'~+\-|()"\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1F1E6}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/, ' ') # Set fuzzy matching for keyword search, right now with automatic Levenshtein Edit Distance # https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html diff --git a/test/lib/check_search_test.rb b/test/lib/check_search_test.rb index 327be1269..8a59c5bd2 100644 --- a/test/lib/check_search_test.rb +++ b/test/lib/check_search_test.rb @@ -16,6 +16,10 @@ def teardown query = 'Something is going to happen on 04/11, reportedly' search = CheckSearch.new({ keyword: query }.to_json, nil, @team.id) assert_equal 'Something is going to happen on 04 11 reportedly', search.instance_variable_get('@options')['keyword'] + + query = "Something is going to happen on Foo's house" + search = CheckSearch.new({ keyword: query }.to_json, nil, @team.id) + assert_equal "Something is going to happen on Foo's house", search.instance_variable_get('@options')['keyword'] end test "should search for array field containing nil values" do