diff options
author | Go MAEDA <maeda@farend.jp> | 2024-06-19 14:27:20 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2024-06-19 14:27:20 +0000 |
commit | 5a96997f6a839d09fe9b22fd1f26d50b766da3e8 (patch) | |
tree | 696ed42376e060900fda650c855982a55ecb3a30 /lib | |
parent | 07307140b97ef8de5a952ae06ddc674bdc2b3f45 (diff) | |
download | redmine-5a96997f6a839d09fe9b22fd1f26d50b766da3e8.tar.gz redmine-5a96997f6a839d09fe9b22fd1f26d50b766da3e8.zip |
Support multiple multi-word phrases in the search engine (#38446).
Patch by Go MAEDA (@maeda).
git-svn-id: https://svn.redmine.org/redmine/trunk@22886 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/search.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/redmine/search.rb b/lib/redmine/search.rb index c07f93aad..6c3ee835c 100644 --- a/lib/redmine/search.rb +++ b/lib/redmine/search.rb @@ -135,7 +135,11 @@ module Redmine def tokens # extract tokens from the question # eg. hello "bye bye" => ["hello", "bye bye"] - tokens = @question.scan(%r{(([[:space:]]|^)"[^"]+"([[:space:]]|$)|[[:^space:]]+)}).collect {|m| m.first.gsub(%r{(^[[:space:]]*"[[:space:]]*|[[:space:]]*"[[:space:]]*$)}, '')} + tokens = @question.scan(/"[^"]+"|[^\p{Zs}]+/).map do |token| + # Remove quotes from quoted tokens, strip surrounding whitespace + # e.g. "\" foo bar \"" => "foo bar" + token.gsub(/\A"\p{Zs}*|\p{Zs}*"\Z/, '') + end # tokens must be at least 2 characters long # but for Chinese characters (Chinese HANZI/Japanese KANJI), tokens can be one character # no more than 5 tokens to search for |