Browse Source

Don't use full text search for exact matches

master
Dylan Baker 2 years ago
parent
commit
48fe82bdbd
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      lib/search.rb

+ 2
- 2
lib/search.rb View File

@@ -66,7 +66,7 @@ def search_threads(q, username, from_date, to_date, sort, offset, exact_match)
66 66
     .offset(Sequel.lit('?', offset))
67 67
 
68 68
   if exact_match
69
-    query.full_text_search(:title, q, phrase: true, language: 'english')
69
+    query.where(Sequel.ilike(:title, "%#{q}%"))
70 70
   else
71 71
     query.full_text_search(:title, Sequel.lit("websearch_to_tsquery(?)", q), tsquery: true, language: 'english')
72 72
   end
@@ -84,7 +84,7 @@ def search_posts(q, username, from_date, to_date, offset, exact_match)
84 84
     .order(Sequel.desc(Sequel.lit('posts.created_at')))
85 85
 
86 86
   if exact_match
87
-    query.full_text_search(:body, q, phrase: true, language: 'english')
87
+    query.where(Sequel.ilike(:body, "%#{q}%"))
88 88
   else
89 89
     query.full_text_search(:tsv, Sequel.lit("websearch_to_tsquery(?)", q), {
90 90
       tsquery: true,

Loading…
Cancel
Save