diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-11-16 07:17:15 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-11-16 07:17:15 -0600 |
commit | 6abae51e47753cc80b440c4234c14cd8232e235f (patch) | |
tree | eb3d71fece5419b882d6128c1ab0e130e121c40a /app/models | |
parent | 9de5952f4e92528a1dd664c188d730229493b707 (diff) |
Regular expressions can now be used in full-text searches. Wrapping a search term in double-quotes treats it as a whole-word match.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/status.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index 47d5f982e..045a4a31a 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -336,6 +336,8 @@ class Status < ApplicationRecord after_create :process_bangtags, if: :local? class << self + include SearchHelper + def search_for(term, account = nil, limit = 33, offset = 0) return none if account.nil? if term.start_with?('me:') @@ -349,7 +351,7 @@ class Status < ApplicationRecord end return none if term.blank? || term.length < 3 query = query.without_reblogs - .where('text ILIKE ?', "%#{sanitize_sql_like(term)}%") + .where('text ~* ?', expand_search_query(term)) .offset(offset).limit(limit) apply_timeline_filters(query, account, true) rescue ActiveRecord::StatementInvalid |