mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 09:10:25 +08:00
add search filter
This commit is contained in:
parent
b2d6e2aa43
commit
90d7718103
3 changed files with 20 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue