diff --git a/app/models/search_observer.rb b/app/models/search_observer.rb index 78233b249..7739801bc 100644 --- a/app/models/search_observer.rb +++ b/app/models/search_observer.rb @@ -66,7 +66,7 @@ class SearchObserver < ActiveRecord::Observer end end if obj.class == User && (obj.username_changed? || obj.name_changed?) - SearchObserver.update_users_index(obj.id, obj.username, obj.name) + SearchObserver.update_users_index(obj.id, obj.username_lower, obj.name.downcase) end if obj.class == Topic && obj.title_changed? diff --git a/db/migrate/20141118011735_correct_username_search.rb b/db/migrate/20141118011735_correct_username_search.rb new file mode 100644 index 000000000..fad33f0f1 --- /dev/null +++ b/db/migrate/20141118011735_correct_username_search.rb @@ -0,0 +1,11 @@ +class CorrectUsernameSearch < ActiveRecord::Migration + def up + execute "update user_search_data + set search_data = TO_TSVECTOR('simple', username_lower || ' ' || lower(name)) + from users + where users.id = user_search_data.user_id" + end + + def down + end +end