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 @@ -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 \

22
library/filter.php

@ -114,20 +114,17 @@ class Filter { @@ -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 { @@ -138,14 +135,9 @@ class Filter {
}
}
if ($words) {
$query = implode(' | ', $words);
}
$query = sprintf('"%s" | "%s" | %s', $query,
$query = sprintf('@title %s | "%s" | %s', $query,
$crc32query,
$query);
implode(' | ', $words));
}
}

Loading…
Cancel
Save