Search with the tenant key

The key has been added and populated so use it for searching.
This commit is contained in:
Donal McBreen
2025-11-21 11:05:43 +00:00
parent d6eeea6727
commit adff4591fe
+3 -1
View File
@@ -44,7 +44,9 @@ class Search::Record < ApplicationRecord
end
scope :matching, ->(query, account_id) do
where("MATCH(#{table_name}.account_key, #{table_name}.content, #{table_name}.title) AGAINST(? IN BOOLEAN MODE)", query)
account_key = "account#{account_id}"
full_query = "+#{account_key} +(#{query})"
where("MATCH(#{table_name}.account_key, #{table_name}.content, #{table_name}.title) AGAINST(? IN BOOLEAN MODE)", full_query)
end
scope :for_user, ->(user) do