mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: user search was stemming
This commit is contained in:
parent
8e31fe4835
commit
fae3eab580
@ -184,7 +184,7 @@ class Search
|
|||||||
|
|
||||||
def user_search
|
def user_search
|
||||||
users = User.includes(:user_search_data)
|
users = User.includes(:user_search_data)
|
||||||
.where("user_search_data.search_data @@ #{ts_query}")
|
.where("user_search_data.search_data @@ #{ts_query("simple")}")
|
||||||
.order("CASE WHEN username_lower = '#{@original_term.downcase}' THEN 0 ELSE 1 END")
|
.order("CASE WHEN username_lower = '#{@original_term.downcase}' THEN 0 ELSE 1 END")
|
||||||
.order("last_posted_at DESC")
|
.order("last_posted_at DESC")
|
||||||
.limit(@limit)
|
.limit(@limit)
|
||||||
@ -249,11 +249,13 @@ class Search
|
|||||||
"TO_TSQUERY(#{locale || query_locale}, #{query})"
|
"TO_TSQUERY(#{locale || query_locale}, #{query})"
|
||||||
end
|
end
|
||||||
|
|
||||||
def ts_query
|
def ts_query(locale=nil)
|
||||||
@ts_query ||= begin
|
if !locale
|
||||||
all_terms = @term.gsub(/[:()&!'"]/,'').split
|
@ts_query ||= begin
|
||||||
query = Post.sanitize(all_terms.map {|t| "#{PG::Connection.escape_string(t)}:*"}.join(" & "))
|
Search.ts_query(@term, locale)
|
||||||
"TO_TSQUERY(#{query_locale}, #{query})"
|
end
|
||||||
|
else
|
||||||
|
Search.ts_query(@term, locale)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user