mirror of
https://github.com/discourse/discourse.git
synced 2026-07-29 15:54:48 -05:00
add search filter
This commit is contained in:
+11
-1
@@ -232,10 +232,20 @@ class Search
|
||||
posts.limit(limit)
|
||||
end
|
||||
|
||||
def query_locale
|
||||
def self.query_locale
|
||||
@query_locale ||= Post.sanitize(Search.long_locale)
|
||||
end
|
||||
|
||||
def query_locale
|
||||
self.class.query_locale
|
||||
end
|
||||
|
||||
def self.ts_query(term)
|
||||
all_terms = term.gsub(/[:()&!'"]/,'').split
|
||||
query = Post.sanitize(all_terms.map {|t| "#{PG::Connection.escape_string(t)}:*"}.join(" & "))
|
||||
"TO_TSQUERY(#{query_locale}, #{query})"
|
||||
end
|
||||
|
||||
def ts_query
|
||||
@ts_query ||= begin
|
||||
all_terms = @term.gsub(/[:()&!'"]/,'').split
|
||||
|
||||
Reference in New Issue
Block a user