Add support for wildcard searches in text fields

#1663
This commit is contained in:
Toks
2013-07-20 16:51:55 -04:00
parent 0e7ce3397d
commit ecfcebe30a
7 changed files with 42 additions and 9 deletions

View File

@@ -24,7 +24,11 @@ class WikiPage < ActiveRecord::Base
end
def body_matches(query)
where("body_index @@ plainto_tsquery(?)", query.to_escaped_for_tsquery_split)
if query =~ /\*/ && CurrentUser.user.is_builder?
where("body ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
else
where("body_index @@ plainto_tsquery(?)", query.to_escaped_for_tsquery_split)
end
end
def search(params = {})