X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/87e18b80684dedc761e669d375f59b548e4ab52f..refs/pull/435/head:/app/Services/SearchService.php diff --git a/app/Services/SearchService.php b/app/Services/SearchService.php index a3186e8f4..3d1d45c3b 100644 --- a/app/Services/SearchService.php +++ b/app/Services/SearchService.php @@ -50,6 +50,15 @@ class SearchService $this->permissionService = $permissionService; } + /** + * Set the database connection + * @param Connection $connection + */ + public function setConnection(Connection $connection) + { + $this->db = $connection; + } + /** * Search all entities in the system. * @param string $searchString @@ -154,6 +163,7 @@ class SearchService // Handle normal search terms if (count($terms['search']) > 0) { $subQuery = $this->db->table('search_terms')->select('entity_id', 'entity_type', \DB::raw('SUM(score) as score')); + $subQuery->where('entity_type', '=', 'BookStack\\' . ucfirst($entityType)); $subQuery->where(function(Builder $query) use ($terms) { foreach ($terms['search'] as $inputTerm) { $query->orWhere('term', 'like', $inputTerm .'%');