diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-12-10 03:52:54 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-12-10 03:52:54 -0600 |
commit | 859763ea02d49abc3ce90926effebc745bd8c97b (patch) | |
tree | 6f0daf283b503ae0c04145b06827623093e3a0b4 /app/helpers | |
parent | 61e3a90e50be6e5dba2d84ef31a7df171eb6be50 (diff) |
handle syntax for `tags:` as `tags: tag1 tag2 "tag3" ...`
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/search_helper.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 7abb2729d..100fdddb9 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -3,12 +3,17 @@ require 'sixarm_ruby_unaccent' module SearchHelper def expand_search_query(query) return '' if query.blank? + query = query.strip.downcase.unaccent + if query.include?(':') query_parts = query.split(':', 2) - if query_parts[0].in?(%w(tags subj text desc)) + if query_parts[0] == 'tags' + query = "^tags .*(#{query_parts[1].split.join('|')})" + elsif query_parts[0].in?(%w(subj text desc)) query = "^#{query_parts[0]} .*#{query_parts[1]}" end end - query.downcase.unaccent.gsub(/"(.*)"/, '\\y\1\\y') + + query.gsub(/"(.*)"/, '\\y\1\\y') end end |