]> Untitled Git - lemmy.git/commitdiff
Adding post body searching. Fixes #507
authorDessalines <tyhou13@gmx.com>
Fri, 7 Feb 2020 16:17:15 +0000 (11:17 -0500)
committerDessalines <tyhou13@gmx.com>
Fri, 7 Feb 2020 16:17:15 +0000 (11:17 -0500)
server/src/db/post_view.rs

index c80d16967202fc98a8faff9dbd49edc757365c69..4d09308d89556281f27fee8f504c3a56fcfc5b28 100644 (file)
@@ -178,7 +178,11 @@ impl<'a> PostQueryBuilder<'a> {
   pub fn search_term<T: MaybeOptional<String>>(mut self, search_term: T) -> Self {
     use super::post_view::post_mview::dsl::*;
     if let Some(search_term) = search_term.get_optional() {
-      self.query = self.query.filter(name.ilike(fuzzy_search(&search_term)));
+      let searcher = fuzzy_search(&search_term);
+      self.query = self
+        .query
+        .filter(name.ilike(searcher.to_owned()))
+        .or_filter(body.ilike(searcher));
     }
     self
   }