Browse Source

make meta fields index separated, set search priority by document title

main
ghost 1 year ago
parent
commit
662351cc46
  1. 12
      config/sphinx.conf.txt
  2. 22
      library/filter.php

12
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`, ':', `host`.`port`, `hostPage`.`uri`), \
CONCAT(`host`.`scheme`, '://', `host`.`name`, `hostPage`.`uri`))), \ CONCAT(`host`.`scheme`, '://', `host`.`name`, `hostPage`.`uri`))), \
REGEXP_REPLACE(`hostPage`.`mime`, '^([A-z-]+)/[A-z-]+.*', '$1') AS `mime`, \ REGEXP_REPLACE(`hostPage`.`mime`, '^([A-z-]+)/[A-z-]+.*', '$1') AS `mime`, \
(SELECT GROUP_CONCAT(CONCAT_WS(' ', `hostPageDescription`.`title`, \ (SELECT GROUP_CONCAT(`hostPageDescription`.`title`) \
`hostPageDescription`.`description`, \
`hostPageDescription`.`keywords`)) \
FROM `hostPageDescription` \ 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` \ FROM `hostPage` \
JOIN `host` ON (`host`.`hostId` = `hostPage`.`hostId`) \ 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 \ WHERE `host`.`status` = '1' AND `hostPage`.`httpCode` = 200 AND `hostPage`.`timeBanned` IS NULL AND `hostPage`.`mime` IS NOT NULL \

22
library/filter.php

@ -114,20 +114,17 @@ class Filter {
$query = str_replace(['-', '_', '/'], ' ', $query); $query = str_replace(['-', '_', '/'], ' ', $query);
// Apply query MATCH rules // Apply query MATCH rules
$words = []; if (false !== strpos($query, '\:\ \ ')) { // URL request
// URL request
if (false !== strpos($query, '\:\ \ ')) {
$query = sprintf('"%s"', $crc32query); $query = sprintf('"%s"', $crc32query);
// @TODO Queries longer than 68 chars unreachable in search index } else if (mb_strlen($query) > 68) { // @TODO Queries longer than 68 chars unreachable in search index
} else if (mb_strlen($query) > 68) {
$query = sprintf('"%s" | (%s*)', $crc32query, substr($query, 0, 67)); $query = sprintf('"%s" | (%s*)', $crc32query, substr($query, 0, 67));
// Default condition } else { // Default condition
} else {
$words = [];
// Remove single char words // Remove single char words
foreach ((array) explode(' ', $query) as $word) { foreach ((array) explode(' ', $query) as $word) {
@ -138,14 +135,9 @@ class Filter {
} }
} }
if ($words) { $query = sprintf('@title %s | "%s" | %s', $query,
$query = implode(' | ', $words);
}
$query = sprintf('"%s" | "%s" | %s', $query,
$crc32query, $crc32query,
$query); implode(' | ', $words));
} }
} }

Loading…
Cancel
Save