about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-12-10 03:26:09 -0600
committermultiple creatures <dev@multiple-creature.party>2019-12-10 03:26:26 -0600
commit91545d4ec4b081b6f0e99e013aa1bfdd9c930596 (patch)
tree94dd62d2c23b36cfc1236be9a55f48bd3046dab9 /app/helpers
parent0dfc7b1b64b334b90e9d2edce49310e6fc295d6f (diff)
make query expander convert `heading: regex to match` shortcut into regex form
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/search_helper.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 0f3d09c36..7abb2729d 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -2,6 +2,13 @@ require 'sixarm_ruby_unaccent'
 
 module SearchHelper
 	def expand_search_query(query)
+    return '' if query.blank?
+    if query.include?(':')
+      query_parts = query.split(':', 2)
+      if query_parts[0].in?(%w(tags subj text desc))
+        query = "^#{query_parts[0]} .*#{query_parts[1]}"
+      end
+    end
     query.downcase.unaccent.gsub(/"(.*)"/, '\\y\1\\y')
   end
 end