Browse Source

fix index size

main
ghost 1 year ago
parent
commit
d119756a41
  1. 5
      config/sphinx.conf.txt
  2. 24
      library/sphinxql.php

5
config/sphinx.conf.txt

@ -14,10 +14,7 @@ source hostPage : common @@ -14,10 +14,7 @@ source hostPage : common
sql_query = \
SELECT `hostPage`.`hostPageId`, \
`hostPage`.`uri`, \
REPLACE(`hostPage`.`uri`, '.', ' '), \
REPLACE(`hostPage`.`uri`, '-', ' '), \
REPLACE(`hostPage`.`uri`, '_', ' '), \
REPLACE(`hostPage`.`uri`, '/', ' '), \
REPLACE(REPLACE(REPLACE(REPLACE(`hostPage`.`uri`, '/', ' '), '_', ' '), '-', ' '), '.', ' ') AS `hostPageURIKeywords`, \
`hostPage`.`rank`, \
`host`.`name`, \
IF (`host`.`port` IS NOT NULL, \

24
library/sphinxql.php

@ -11,9 +11,18 @@ class SphinxQL { @@ -11,9 +11,18 @@ class SphinxQL {
$this->_sphinx->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
}
public function searchHostPagesTotal(string $keyword, string $mime) {
$query = $this->_sphinx->prepare('SELECT COUNT(*) AS `total` FROM `hostPage` WHERE MATCH(?) AND `mime` = ?');
$query->execute([$keyword, $mime]);
return $query->fetch()->total;
}
public function searchHostPages(string $keyword, string $mime, int $start, int $limit, int $maxMatches) {
$query = $this->_sphinx->prepare('SELECT *, WEIGHT() + `rank` * IF (`rank` > 0, 1000, 1) AS `priority`
$query = $this->_sphinx->prepare("SELECT *, WEIGHT() + `rank` * IF (`rank` > 0, 1000, 1) AS `priority`
FROM `hostPage`
@ -21,9 +30,9 @@ class SphinxQL { @@ -21,9 +30,9 @@ class SphinxQL {
ORDER BY `priority` DESC, WEIGHT() DESC
LIMIT ' . (int) ($start >= $maxMatches ? ($maxMatches > 0 ? $maxMatches - 1 : 0) : $start) . ',' . (int) $limit . '
LIMIT " . (int) ($start >= $maxMatches ? ($maxMatches > 0 ? $maxMatches - 1 : 0) : $start) . "," . (int) $limit . "
OPTION `max_matches`=' . (int) ($maxMatches >= 1 ? $maxMatches : 1));
OPTION `max_matches`=" . (int) ($maxMatches >= 1 ? $maxMatches : 1));
$query->execute([$keyword, $mime]);
@ -65,13 +74,4 @@ class SphinxQL { @@ -65,13 +74,4 @@ class SphinxQL {
return $query->fetchAll();
}
public function searchHostPagesTotal(string $keyword, string $mime) {
$query = $this->_sphinx->prepare('SELECT COUNT(*) AS `total` FROM `hostPage` WHERE MATCH(?) AND `mime` = ?');
$query->execute([$keyword, $mime]);
return $query->fetch()->total;
}
}

Loading…
Cancel
Save