Lower min_chars_for_partial_matching if CJK chars

parent b05de5a5
Pipeline #67049934 passed with stages
in 67 minutes and 13 seconds
......@@ -129,7 +129,7 @@ class Label < ApplicationRecord
# Override Gitlab::SQL::Pattern.min_chars_for_partial_matching as
# label queries are never global, and so will not use a trigram
# index. That means we can have just one character in the LIKE.
def self.min_chars_for_partial_matching
def self.min_chars_for_partial_matching(_query)
1
end
......
......@@ -7,6 +7,7 @@ module Gitlab
MIN_CHARS_FOR_PARTIAL_MATCHING = 3
REGEX_QUOTED_WORD = /(?<=\A| )"[^"]+"(?= |\z)/.freeze
REGEX_CJK = /\A[\p{Katakana}|\p{Hiragana}|\p{Han}|\p{Hangul}]{1,2}\z/.freeze
class_methods do
def fuzzy_search(query, columns)
......@@ -23,12 +24,12 @@ module Gitlab
end
end
def min_chars_for_partial_matching
MIN_CHARS_FOR_PARTIAL_MATCHING
def min_chars_for_partial_matching(query = '')
query.match?(REGEX_CJK) ? 1 : MIN_CHARS_FOR_PARTIAL_MATCHING
end
def partial_matching?(query)
query.length >= min_chars_for_partial_matching
query.length >= min_chars_for_partial_matching(query)
end
# column - The column name to search in.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment