diff --git a/config/sphinx.conf.txt b/config/sphinx.conf.txt index 58587d1..5b8e481 100644 --- a/config/sphinx.conf.txt +++ b/config/sphinx.conf.txt @@ -33,11 +33,15 @@ source hostPage : common CONCAT(`host`.`scheme`, '://', `host`.`name`, ':', `host`.`port`, `hostPage`.`uri`), \ CONCAT(`host`.`scheme`, '://', `host`.`name`, `hostPage`.`uri`))), \ REGEXP_REPLACE(`hostPage`.`mime`, '^([A-z-]+)/[A-z-]+.*', '$1') AS `mime`, \ - (SELECT GROUP_CONCAT(CONCAT_WS(' ', `hostPageDescription`.`title`, \ - `hostPageDescription`.`description`, \ - `hostPageDescription`.`keywords`)) \ + (SELECT GROUP_CONCAT(`hostPageDescription`.`title`) \ FROM `hostPageDescription` \ - WHERE `hostPageDescription`.`hostPageId` = `hostPage`.`hostPageId`) AS `pageDescription` \ + WHERE `hostPageDescription`.`hostPageId` = `hostPage`.`hostPageId`) AS `title`, \ + (SELECT GROUP_CONCAT(`hostPageDescription`.`description`) \ + FROM `hostPageDescription` \ + WHERE `hostPageDescription`.`hostPageId` = `hostPage`.`hostPageId`) AS `description`, \ + (SELECT GROUP_CONCAT(`hostPageDescription`.`keywords`) \ + FROM `hostPageDescription` \ + WHERE `hostPageDescription`.`hostPageId` = `hostPage`.`hostPageId`) AS `keywords` \ FROM `hostPage` \ JOIN `host` ON (`host`.`hostId` = `hostPage`.`hostId`) \ WHERE `host`.`status` = '1' AND `hostPage`.`httpCode` = 200 AND `hostPage`.`timeBanned` IS NULL AND `hostPage`.`mime` IS NOT NULL \ diff --git a/library/filter.php b/library/filter.php index f1e151c..958098e 100644 --- a/library/filter.php +++ b/library/filter.php @@ -114,20 +114,17 @@ class Filter { $query = str_replace(['-', '_', '/'], ' ', $query); // Apply query MATCH rules - $words = []; - - // URL request - if (false !== strpos($query, '\:\ \ ')) { + if (false !== strpos($query, '\:\ \ ')) { // URL request $query = sprintf('"%s"', $crc32query); - // @TODO Queries longer than 68 chars unreachable in search index - } else if (mb_strlen($query) > 68) { + } else if (mb_strlen($query) > 68) { // @TODO Queries longer than 68 chars unreachable in search index $query = sprintf('"%s" | (%s*)', $crc32query, substr($query, 0, 67)); - // Default condition - } else { + } else { // Default condition + + $words = []; // Remove single char words foreach ((array) explode(' ', $query) as $word) { @@ -138,14 +135,9 @@ class Filter { } } - if ($words) { - - $query = implode(' | ', $words); - } - - $query = sprintf('"%s" | "%s" | %s', $query, - $crc32query, - $query); + $query = sprintf('@title %s | "%s" | %s', $query, + $crc32query, + implode(' | ', $words)); } }