blob: 9510abe99e08ba2a94296af0a4ae074a48c91fd4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
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 %w(tag tags).include?(query_parts[0])
query = "^tag (#{query_parts[1].split.join('|')})"
elsif %w(subj text desc).include?(query_parts[0])
query = "^#{query_parts[0]} .*#{query_parts[1]}"
end
end
query.gsub(/"(.*)"/, '\\y\1\\y')
end
end
|