Ejemplo n.º 1
0
<?php

require_once realpath(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ReleaseSearch;
use nzedb\SphinxSearch;
use nzedb\db\DB;
if (nZEDb_RELEASE_SEARCH_TYPE != ReleaseSearch::SPHINX) {
    exit('Error, nZEDb_RELEASE_SEARCH_TYPE in nzedb/config/settings.php must be set to SPHINX!' . PHP_EOL);
} else {
    if (!isset($argv[1]) || !in_array($argv[1], ['releases_rt'])) {
        exit("Argument 1 is the index name, releases_rt are the only supported ones currently.\n" . "Argument 2 is optional, max number of rows to send to sphinx at a time, 10,000 is the default if not set.\n" . "              The value of 10,000 is good for the default sphinx.conf max_packet_size of 8M, if you want\n" . "              to raise this higher than 10,000, raise the sphinx.conf max_packet_size higher than  8M.\n" . "              If you have many releases, raise the sphinx.conf max_packet_size to 128M (the maximum), restart sphinx and\n" . "              and set Argument 2 to 250,000. This will speed up the script tremendously.\n");
    } else {
        populate_rt($argv[1], isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : 10000);
    }
}
// Bulk insert releases into sphinx RT index.
function populate_rt($table, $max)
{
    $pdo = new DB();
    switch ($table) {
        case 'releases_rt':
            $pdo->queryDirect('SET SESSION group_concat_max_len=8192');
            $query = 'SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename
				FROM releases r
				LEFT JOIN release_files rf ON(r.id=rf.releaseid)
				WHERE r.id > %d
				GROUP BY r.id
				ORDER BY r.id ASC
				LIMIT %d';
            $rtvalues = '(id, name, searchname, fromname, filename)';
            $totals = $pdo->queryOneRow("SELECT COUNT(id) AS c, MIN(id) AS min FROM releases");
Ejemplo n.º 2
0
<?php

require_once realpath(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ReleaseSearch;
use nzedb\SphinxSearch;
use nzedb\db\DB;
if (nZEDb_RELEASE_SEARCH_TYPE != ReleaseSearch::SPHINX) {
    exit('Error, nZEDb_RELEASE_SEARCH_TYPE in nzedb/config/settings.php must be set to SPHINX!' . PHP_EOL);
} else {
    if (!isset($argv[1]) || !in_array($argv[1], ['releases_rt'])) {
        exit('Argument1 is the index name, releases_rt are the only supported ones currently.' . PHP_EOL);
    } else {
        populate_rt($argv[1]);
    }
}
// Bulk insert releases into sphinx RT index.
function populate_rt($table = '')
{
    $pdo = new DB();
    $rows = false;
    switch ($table) {
        case 'releases_rt':
            $pdo->queryDirect('SET SESSION group_concat_max_len=8192');
            $rows = $pdo->queryExec('SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename
				FROM releases r LEFT JOIN release_files rf ON(r.id=rf.releaseid) GROUP BY r.id');
            $rtvalues = '(id, name, searchname, fromname, filename)';
            break;
    }
    if ($rows !== false && ($total = $rows->rowCount())) {
        $sphinx = new SphinxSearch();
        $string = sprintf('REPLACE INTO %s %s VALUES ', $table, $rtvalues);