diff --git a/Blacklight/IRCScraper.php b/Blacklight/IRCScraper.php index 08b334d11..6fc89df02 100755 --- a/Blacklight/IRCScraper.php +++ b/Blacklight/IRCScraper.php @@ -61,17 +61,17 @@ class IRCScraper extends IRCClient * * @var string|bool */ - protected $_titleIgnoreRegex; + protected mixed $_titleIgnoreRegex; /** - * @var \Blacklight\SphinxSearch + * @var \Blacklight\ManticoreSearch */ - protected $sphinxsearch; + protected manticoreSearch $manticoreSearch; /** * @var ElasticSearchSiteSearch */ - private $elasticsearch; + private ElasticSearchSiteSearch $elasticsearch; /** * Construct. @@ -145,7 +145,7 @@ class IRCScraper extends IRCClient } $this->elasticsearch = new ElasticSearchSiteSearch(); - $this->sphinxsearch = new SphinxSearch(); + $this->manticoreSearch = new manticoreSearch(); $this->_groupList = []; $this->_silent = $silent; @@ -302,7 +302,7 @@ class IRCScraper extends IRCClient if (config('nntmux.elasticsearch_enabled') === true) { $indexData = (new ElasticSearchSiteSearch())->predbIndexSearch($this->_curPre['title']); } else { - $indexData = $this->sphinxsearch->searchIndexes('predb_rt', $this->_curPre['title'], ['title']); + $indexData = $this->manticoreSearch->searchIndexes('predb_rt', $this->_curPre['title'], ['title']); } if (! empty($indexData) || empty($this->_curPre['title'])) { return; @@ -352,7 +352,7 @@ class IRCScraper extends IRCClient if (config('nntmux.elasticsearch_enabled') === true) { $this->elasticsearch->insertPreDb($parameters); } else { - $this->sphinxsearch->insertPredb($parameters); + $this->manticoreSearch->insertPredb($parameters); } $this->_doEcho(true); @@ -406,7 +406,7 @@ class IRCScraper extends IRCClient if (config('nntmux.elasticsearch_enabled') === true) { $this->elasticsearch->updatePreDb($parameters); } else { - $this->sphinxsearch->updatePreDb($parameters); + $this->manticoreSearch->updatePreDb($parameters); } $this->_doEcho(false); diff --git a/Blacklight/SphinxSearch.php b/Blacklight/ManticoreSearch.php old mode 100755 new mode 100644 similarity index 53% rename from Blacklight/SphinxSearch.php rename to Blacklight/ManticoreSearch.php index 669511ae6..ed1238725 --- a/Blacklight/SphinxSearch.php +++ b/Blacklight/ManticoreSearch.php @@ -4,89 +4,61 @@ namespace Blacklight; use App\Models\Predb; use App\Models\Release; -use Foolz\SphinxQL\Drivers\Pdo\Connection; -use Foolz\SphinxQL\Exception\DatabaseException; -use Foolz\SphinxQL\Exception\SphinxQLException; -use Foolz\SphinxQL\Helper; -use Foolz\SphinxQL\SphinxQL; use Illuminate\Support\Facades\DB; +use Manticoresearch\Client; +use Manticoresearch\Exceptions\ResponseException; +use Manticoresearch\Exceptions\RuntimeException; /** - * Class SphinxSearch. + * Class ManticoreSearch. */ -class SphinxSearch +class ManticoreSearch { - public SphinxQL $sphinxQL; - - protected Connection $connection; - /** * @var \Illuminate\Config\Repository|mixed */ protected mixed $config; - protected Helper $helper; - /** * @var \Blacklight\ColorCLI */ private ColorCLI $cli; /** - * Establish connection to SphinxQL. - * - * @throws \Exception + * Establishes a connection to ManticoreSearch HTTP port. */ public function __construct() { - $this->connection = new Connection(); $this->config = config('sphinxsearch'); - $this->connection->setParams(['host' => $this->config['host'], 'port' => $this->config['port']]); - $this->sphinxQL = new SphinxQL($this->connection); - $this->helper = new Helper($this->connection); + $this->connection = ['host' => $this->config['host'], 'port' => $this->config['port']]; + $this->manticoresearch = new Client($this->connection); $this->cli = new ColorCLI(); } /** - * Insert release into Sphinx RT table. - * - * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException + * Insert release into ManticoreSearch releases_rt realtime index */ public function insertRelease(array $parameters): void { if ($parameters['id']) { - $this->sphinxQL - ->replace() - ->into($this->config['indexes']['releases']) - ->set(['id' => $parameters['id'], 'name' => $parameters['name'], 'searchname' => $parameters['searchname'], 'fromname' => $parameters['fromname'], 'categories_id' => (string) $parameters['categories_id'], 'filename' => empty($parameters['filename']) ? "''" : $parameters['filename']]) - ->execute(); + $this->manticoresearch->index($this->config['indexes']['releases']) + ->replaceDocument(['name' => $parameters['name'], 'searchname' => $parameters['searchname'], 'fromname' => $parameters['fromname'], 'categories_id' => (string) $parameters['categories_id'], 'filename' => empty($parameters['filename']) ? "''" : $parameters['filename']], $parameters['id']); } } /** - * Insert release into Sphinx RT table. - * - * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException + * Insert release into Manticore RT table. */ public function insertPredb(array $parameters): void { if ($parameters['id']) { - $this->sphinxQL - ->replace() - ->into($this->config['indexes']['predb']) - ->set(['id' => $parameters['id'], 'title' => $parameters['title'], 'filename' => empty($parameters['filename']) ? "''" : $parameters['filename'], 'source' => $parameters['source']]) - ->execute(); + $this->manticoresearch->index($this->config['indexes']['predb']) + ->replaceDocument(['title' => $parameters['title'], 'filename' => empty($parameters['filename']) ? "''" : $parameters['filename'], 'source' => $parameters['source']], $parameters['id']); } } /** - * Delete release from Sphinx RT tables. + * Delete release from Manticore RT tables. * * @param array $identifiers ['g' => Release GUID(mandatory), 'id' => ReleaseID(optional, pass false)] */ @@ -99,7 +71,7 @@ class SphinxSearch } } if ($identifiers['i'] !== false) { - $this->sphinxQL->delete()->from([$this->config['indexes']['releases']])->where('id', '=', $identifiers['i']); + $this->manticoresearch->index($this->config['indexes']['releases'])->deleteDocument($identifiers['i']); } } @@ -118,7 +90,7 @@ class SphinxSearch } /** - * Update Sphinx Relases index for given releases_id. + * Update Manticore Relases index for given releases_id. * * * @throws \Exception @@ -138,7 +110,7 @@ class SphinxSearch } /** - * Update Sphinx Predb index for given predb_id. + * Update Manticore Predb index for given predb_id. * * * @throws \Exception @@ -150,11 +122,6 @@ class SphinxSearch } } - /** - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException - */ public function truncateRTIndex(array $indexes = []): bool { if (empty($indexes)) { @@ -164,8 +131,28 @@ class SphinxSearch } foreach ($indexes as $index) { if (\in_array($index, $this->config['indexes'], true)) { - $this->helper->truncateRtIndex($index)->execute(); - $this->cli->info('Truncating index '.$index.' finished.'); + try { + $this->manticoresearch->index($index)->truncate(); + $this->cli->info('Truncating index '.$index.' finished.'); + } catch (ResponseException $e) { + if ($e->getMessage() === 'Invalid index') { + if ($index === 'releases_rt') { + $this->manticoresearch->index($index)->create([ + 'name' => ['type' => 'string'], + 'searchname' => ['type' => 'string'], + 'fromname' => ['type' => 'string'], + 'filename' => ['type' => 'string'], + 'categories_id' => ['type' => 'integer'], + ]); + } elseif ($index === 'predb_rt') { + $this->manticoresearch->index($index)->create([ + 'title' => ['type' => 'string'], + 'filename' => ['type' => 'string'], + 'source' => ['type' => 'string'], + ]); + } + } + } } else { $this->cli->error('Unsupported index: '.$index); } @@ -180,8 +167,8 @@ class SphinxSearch public function optimizeRTIndex(): void { foreach ($this->config['indexes'] as $index) { - $this->helper->flushRtIndex($index)->execute(); - $this->helper->optimizeIndex($index)->execute(); + $this->manticoresearch->index($index)->flush(); + $this->manticoresearch->index($index)->optimize(); } } @@ -189,29 +176,30 @@ class SphinxSearch * @param string $rt_index (releases_rt or predb_rt) * @param string $searchString (what are we looking for?) * @param array $column (one or multiple columns from the columns that exist in indexes) - * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ - public function searchIndexes(string $rt_index, string $searchString = '', array $column = [], array $searchArray = []): array + public function searchIndexes(string $rt_index, string $searchString = '', array $column = [], array $searchArray = []): mixed { - $query = $this->sphinxQL->select()->from($rt_index)->option('max_matches', 10000)->option('ranker', 'sph04')->option('sort_method', 'pq')->limit(0, 10000)->orderBy('id', 'desc'); + $result = []; + $query = $this->manticoresearch->index($rt_index)->search($searchString)->maxMatches(10000)->option('ranker', 'sph04')->option('sort_method', 'pq')->limit(10000)->sort('id', 'desc'); if (! empty($searchArray)) { foreach ($searchArray as $key => $value) { - $query->match($key, $value, true); + $query->match($value, $key); } } elseif (! empty($searchString)) { - $query->match($column, $searchString, true); + $query->match($searchString, $column); } else { return []; } try { - return $query->execute()->fetchAllAssoc() ?? []; - } catch (SphinxQLException $exception) { + $results = $query->get(); + foreach ($results as $doc) { + $result[] = $doc->getId(); + } + return $result; + } catch (ResponseException $exception) { return []; - } catch (DatabaseException $databaseException) { + } catch (RuntimeException $exception) { return []; } } diff --git a/Blacklight/NameFixer.php b/Blacklight/NameFixer.php index 0383b33d2..cee8e91f1 100755 --- a/Blacklight/NameFixer.php +++ b/Blacklight/NameFixer.php @@ -115,9 +115,9 @@ class NameFixer public Utility $text; /** - * @var \Blacklight\SphinxSearch + * @var \Blacklight\ManticoreSearch */ - public mixed $sphinx; + public mixed $manticore; /** * @var \Blacklight\ColorCLI @@ -140,7 +140,7 @@ class NameFixer 'Groups' => null, 'Misc' => null, 'Settings' => null, - 'SphinxSearch' => null, + 'ManticoreSearch' => null, ]; $options += $defaults; @@ -155,7 +155,7 @@ class NameFixer $this->done = $this->matched = false; $this->consoletools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools()); $this->category = ($options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => null])); - $this->sphinx = ($options['SphinxSearch'] instanceof SphinxSearch ? $options['SphinxSearch'] : new SphinxSearch()); + $this->manticore = ($options['ManticoreSearch'] instanceof ManticoreSearch ? $options['ManticoreSearch'] : new ManticoreSearch()); $this->elasticsearch = new ElasticSearchSiteSearch(); } @@ -967,7 +967,7 @@ class NameFixer if (config('nntmux.elasticsearch_enabled') === true) { $this->elasticsearch->updateRelease($release->releases_id); } else { - $this->sphinx->updateRelease($release->releases_id); + $this->manticore->updateRelease($release->releases_id); } } else { $release->update( @@ -989,7 +989,7 @@ class NameFixer if (config('nntmux.elasticsearch_enabled') === true) { $this->elasticsearch->updateRelease($release->_releases_id); } else { - $this->sphinx->updateRelease($release->releases_id); + $this->manticore->updateRelease($release->releases_id); } } } @@ -1090,17 +1090,13 @@ class NameFixer return $matching; } - /** - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException - */ + protected function _preFTsearchQuery($preTitle): string { $join = ''; if (\strlen($preTitle) >= 15 && preg_match(self::PREDB_REGEX, $preTitle)) { - $titleMatch = $this->sphinx->searchIndexes('releases_rt', $preTitle, ['name', 'searchname', 'filename']); + $titleMatch = $this->manticore->searchIndexes('releases_rt', $preTitle, ['name', 'searchname', 'filename']); if (! empty($titleMatch)) { $join = implode(',', Arr::pluck($titleMatch, 'id')); } @@ -1195,7 +1191,7 @@ class NameFixer if (config('nntmux.elasticsearch_enabled') === true) { $results = $this->elasticsearch->searchPreDb($preMatch[1]); } else { - $results = $this->sphinx->searchIndexes('predb_rt', $preMatch[1], ['filename', 'title']); + $results = $this->manticore->searchIndexes('predb_rt', $preMatch[1], ['filename', 'title']); } if (! empty($results)) { foreach ($results as $result) { @@ -2244,7 +2240,7 @@ class NameFixer } } } else { - foreach ($this->sphinx->searchIndexes('predb_rt', $this->_fileName, ['filename', 'title']) as $hit) { + foreach ($this->manticore->searchIndexes('predb_rt', $this->_fileName, ['filename', 'title']) as $hit) { if (! empty($hit)) { $this->updateRelease($release, $hit['title'], 'PreDb: Filename match', $echo, $type, $nameStatus, $show, $hit['id']); @@ -2276,7 +2272,7 @@ class NameFixer } } } else { - foreach ($this->sphinx->searchIndexes('predb_rt', $this->_fileName, ['title']) as $hit) { + foreach ($this->manticore->searchIndexes('predb_rt', $this->_fileName, ['title']) as $hit) { if (! empty($hit)) { $this->updateRelease($release, $hit['title'], 'PreDb: Title match', $echo, $type, $nameStatus, $show, $hit['id']); diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index f50ada469..3cc969eed 100644 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -24,9 +24,9 @@ class Releases extends Release public const PASSWD_RAR = 1; // Definitely passworded. /** - * @var \Blacklight\SphinxSearch + * @var \Blacklight\ManticoreSearch */ - public SphinxSearch $sphinxSearch; + public ManticoreSearch $manticoreSearch; public int $passwordStatus; @@ -40,7 +40,7 @@ class Releases extends Release public function __construct() { parent::__construct(); - $this->sphinxSearch = new SphinxSearch(); + $this->manticoreSearch = new ManticoreSearch(); $this->elasticSearch = new ElasticSearchSiteSearch(); } @@ -382,7 +382,7 @@ class Releases extends Release } } else { // Delete from sphinx. - $this->sphinxSearch->deleteRelease($identifiers); + $this->manticoreSearch->deleteRelease($identifiers); } // Delete from DB. @@ -439,9 +439,6 @@ class Releases extends Release * * @return array|Collection|mixed * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ public function search(array $searchArr, $groupName, $sizeFrom, $sizeTo, $daysNew, $daysOld, int $offset = 0, int $limit = 1000, array|string $orderBy = '', int $maxAge = -1, array $excludedCats = [], string $type = 'basic', array $cat = [-1], int $minSize = 0, array $tags = []): mixed { @@ -475,9 +472,8 @@ class Releases extends Release if (config('nntmux.elasticsearch_enabled') === true) { $searchResult = $this->elasticSearch->indexSearch($phrases, $limit); } else { - $results = $this->sphinxSearch->searchIndexes('releases_rt', '', [], $searchFields); + $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', '', [], $searchFields); - $searchResult = Arr::pluck($results, 'id'); } if (empty($searchResult)) { @@ -561,9 +557,6 @@ class Releases extends Release * * @return Collection|mixed * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ public function apiSearch($searchName, $groupName, int $offset = 0, int $limit = 1000, int $maxAge = -1, array $excludedCats = [], array $cat = [-1], int $minSize = 0, array $tags = []): mixed { @@ -571,7 +564,7 @@ class Releases extends Release if (config('nntmux.elasticsearch_enabled') === true) { $searchResult = $this->elasticSearch->indexSearchApi($searchName, $limit); } else { - $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $searchName, ['searchname']), 'id'); + $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $searchName, ['searchname']); } } @@ -644,9 +637,6 @@ class Releases extends Release * * @return array|\Illuminate\Cache\|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|mixed * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ public function tvSearch(array $siteIdArr = [], string $series = '', string $episode = '', string $airDate = '', int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = [], array $tags = []): mixed { @@ -708,7 +698,7 @@ class Releases extends Release if (config('nntmux.elasticsearch_enabled') === true) { $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit); } else { - $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); + $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']); } if (empty($searchResult)) { @@ -782,9 +772,6 @@ class Releases extends Release * * @return Collection|mixed * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ public function apiTvSearch(array $siteIdArr = [], string $series = '', string $episode = '', string $airDate = '', int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = [], array $tags = []): mixed { @@ -846,7 +833,7 @@ class Releases extends Release if (config('nntmux.elasticsearch_enabled') === true) { $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit); } else { - $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); + $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']); } if (empty($searchResult)) { @@ -914,9 +901,6 @@ class Releases extends Release * * @return Collection|mixed * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ public function animeSearch($aniDbID, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, array $excludedCategories = []): mixed { @@ -924,7 +908,7 @@ class Releases extends Release if (config('nntmux.elasticsearch_enabled') === true) { $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit); } else { - $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); + $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']); } if (empty($searchResult)) { @@ -987,9 +971,6 @@ class Releases extends Release * * @return Collection|mixed * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ public function moviesSearch(int $imDbId = -1, int $tmDbId = -1, int $traktId = -1, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = [], array $tags = []): mixed { @@ -997,7 +978,7 @@ class Releases extends Release if (config('nntmux.elasticsearch_enabled') === true) { $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit); } else { - $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); + $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']); } if (empty($searchResult)) { @@ -1061,9 +1042,10 @@ class Releases extends Release } /** - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException + * @param $currentID + * @param $name + * @param array $excludedCats + * @return bool|array */ public function searchSimilar($currentID, $name, array $excludedCats = []): bool|array { diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php index d8542e672..762a8dcb3 100755 --- a/Blacklight/processing/post/ProcessAdditional.php +++ b/Blacklight/processing/post/ProcessAdditional.php @@ -18,7 +18,7 @@ use Blacklight\NZB; use Blacklight\ReleaseExtra; use Blacklight\ReleaseImage; use Blacklight\Releases; -use Blacklight\SphinxSearch; +use Blacklight\ManticoreSearch; use Blacklight\utility\Utility; use dariusiii\rarinfo\ArchiveInfo; use dariusiii\rarinfo\Par2Info; @@ -245,7 +245,7 @@ class ProcessAdditional */ protected bool $_reverse; - protected SphinxSearch $sphinx; + protected ManticoreSearch $manticore; private FFMpeg $ffmpeg; @@ -274,7 +274,7 @@ class ProcessAdditional 'ReleaseExtra' => null, 'ReleaseImage' => null, 'Settings' => null, - 'SphinxSearch' => null, + 'ManticoreSearch' => null, ]; $options += $defaults; @@ -290,7 +290,7 @@ class ProcessAdditional $this->_releaseImage = $options['ReleaseImage'] ?? new ReleaseImage(); $this->_par2Info = new Par2Info(); $this->_nfo = $options['Nfo'] ?? new Nfo(); - $this->sphinx = $options['SphinxSearch'] ?? new SphinxSearch(); + $this->manticore = $options['ManticoreSearch'] ?? new ManticoreSearch(); $this->elasticsearch = new ElasticSearchSiteSearch(); $this->ffmpeg = FFMpeg::create(['timeout' => Settings::settingValue('..timeoutseconds')]); $this->ffprobe = FFProbe::create(); @@ -1040,7 +1040,7 @@ class ProcessAdditional if (config('nntmux.elasticsearch_enabled') === true) { $this->elasticsearch->updateRelease($this->_release->id); } else { - $this->sphinx->updateRelease($this->_release->id); + $this->manticore->updateRelease($this->_release->id); } } @@ -1571,7 +1571,7 @@ class ProcessAdditional if (config('nntmux.elasticsearch_enabled') === true) { $this->elasticsearch->updateRelease($this->_release->id); } else { - $this->sphinx->updateRelease($this->_release->id); + $this->manticore->updateRelease($this->_release->id); } // Echo the changed name. diff --git a/app/Console/Commands/NntmuxResetDb.php b/app/Console/Commands/NntmuxResetDb.php index 5db6de8d4..cdd482940 100644 --- a/app/Console/Commands/NntmuxResetDb.php +++ b/app/Console/Commands/NntmuxResetDb.php @@ -4,7 +4,7 @@ namespace App\Console\Commands; use App\Models\Settings; use App\Models\UsenetGroup; -use Blacklight\SphinxSearch; +use Blacklight\ManticoreSearch; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; @@ -168,7 +168,7 @@ class NntmuxResetDb extends Command $this->info('All done! ElasticSearch indexes are deleted and recreated.'); } else { - (new SphinxSearch())->truncateRTIndex(['releases_rt', 'predb_rt']); + (new ManticoreSearch())->truncateRTIndex(['releases_rt', 'predb_rt']); } $this->info('Deleting nzbfiles subfolders.'); diff --git a/app/Http/Controllers/Api/ApiV2Controller.php b/app/Http/Controllers/Api/ApiV2Controller.php index 8676bb39c..5f8f706a2 100644 --- a/app/Http/Controllers/Api/ApiV2Controller.php +++ b/app/Http/Controllers/Api/ApiV2Controller.php @@ -53,9 +53,8 @@ class ApiV2Controller extends BasePageController } /** - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\JsonResponse * @throws \Throwable */ public function movie(Request $request): JsonResponse diff --git a/app/Http/Controllers/DetailsController.php b/app/Http/Controllers/DetailsController.php index f527976b7..2ab5a06c1 100644 --- a/app/Http/Controllers/DetailsController.php +++ b/app/Http/Controllers/DetailsController.php @@ -27,9 +27,6 @@ class DetailsController extends BasePageController /** * @return \Illuminate\Http\RedirectResponse|void * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException * @throws \Exception */ public function show(string $guid) diff --git a/app/Models/Predb.php b/app/Models/Predb.php index d8c6c8296..5da56dffb 100644 --- a/app/Models/Predb.php +++ b/app/Models/Predb.php @@ -5,7 +5,7 @@ namespace App\Models; use Blacklight\ColorCLI; use Blacklight\ConsoleTools; use Blacklight\ElasticSearchSiteSearch; -use Blacklight\SphinxSearch; +use Blacklight\ManticoreSearch; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Cache; @@ -102,11 +102,11 @@ class Predb extends Model /** * Attempts to match PreDB titles to releases. * - * @param string|int|bool $dateLimit + * @param bool|int|string $dateLimit * * @throws \RuntimeException */ - public static function checkPre($dateLimit = false): void + public static function checkPre(bool|int|string $dateLimit = false): void { $consoleTools = new ConsoleTools(); $updated = 0; @@ -202,8 +202,8 @@ class Predb extends Model if (config('nntmux.elasticsearch_enabled') === true) { $ids = (new ElasticSearchSiteSearch())->predbIndexSearch($search); } else { - $sphinx = new SphinxSearch(); - $ids = Arr::pluck($sphinx->searchIndexes('predb_rt', $search, ['title']), 'id'); + $manticore = new ManticoreSearch(); + $ids = Arr::pluck($manticore->searchIndexes('predb_rt', $search, ['title']), 'id'); } $sql->whereIn('predb.id', $ids); } diff --git a/app/Models/Release.php b/app/Models/Release.php index cc9c83bea..08a798283 100644 --- a/app/Models/Release.php +++ b/app/Models/Release.php @@ -4,7 +4,7 @@ namespace App\Models; use Blacklight\ElasticSearchSiteSearch; use Blacklight\NZB; -use Blacklight\SphinxSearch; +use Blacklight\ManticoreSearch; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; @@ -300,7 +300,7 @@ class Release extends Model if (config('nntmux.elasticsearch_enabled') === true) { (new ElasticSearchSiteSearch())->insertRelease($parameters); } else { - (new SphinxSearch())->insertRelease($parameters); + (new ManticoreSearch())->insertRelease($parameters); } return $parameters['id']; @@ -337,7 +337,7 @@ class Release extends Model if (config('nntmux.elasticsearch_enabled') === true) { (new ElasticSearchSiteSearch())->updateRelease($id); } else { - (new SphinxSearch())->updateRelease($id); + (new ManticoreSearch())->updateRelease($id); } } @@ -559,9 +559,6 @@ class Release extends Model * * @return false|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Query\Builder|object|null * - * @throws \Foolz\SphinxQL\Exception\ConnectionException - * @throws \Foolz\SphinxQL\Exception\DatabaseException - * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ public static function getAlternate($guid, $userid) { @@ -578,7 +575,7 @@ class Release extends Model if (config('nntmux.elasticsearch_enabled') === true) { $searchResult = (new ElasticSearchSiteSearch())->indexSearch($similar[1], 10); } else { - $results = (new SphinxSearch())->searchIndexes('releases_rt', $similar[1]); + $results = (new ManticoreSearch())->searchIndexes('releases_rt', $similar[1]); $searchResult = Arr::pluck($results, 'id'); } diff --git a/app/Models/ReleaseFile.php b/app/Models/ReleaseFile.php index b44a87702..cc2da8e89 100644 --- a/app/Models/ReleaseFile.php +++ b/app/Models/ReleaseFile.php @@ -3,7 +3,7 @@ namespace App\Models; use Blacklight\ElasticSearchSiteSearch; -use Blacklight\SphinxSearch; +use Blacklight\ManticoreSearch; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Log; @@ -129,7 +129,7 @@ class ReleaseFile extends Model if (config('nntmux.elasticsearch_enabled') === true) { (new ElasticSearchSiteSearch())->updateRelease($id); } else { - (new SphinxSearch())->updateRelease($id); + (new ManticoreSearch())->updateRelease($id); } } diff --git a/config/sphinxsearch.php b/config/sphinxsearch.php index d66921ce1..eff56cd47 100644 --- a/config/sphinxsearch.php +++ b/config/sphinxsearch.php @@ -2,7 +2,7 @@ return [ 'host' => env('MANTICORESEARCH_HOST', '127.0.0.1'), - 'port' => env('MANTICORESEARCH_PORT', 9306), + 'port' => env('MANTICORESEARCH_PORT', 9308), 'indexes' => [ 'releases' => 'releases_rt', 'predb' => 'predb_rt', diff --git a/misc/elasticsearch/populate_es_indexes.php b/misc/elasticsearch/populate_es_indexes.php index aafffa5f0..5090f1257 100644 --- a/misc/elasticsearch/populate_es_indexes.php +++ b/misc/elasticsearch/populate_es_indexes.php @@ -15,7 +15,7 @@ if (! isset($argv[1])) { populate_indexes($argv[1], (isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : 10000)); -// Bulk insert releases into sphinx RT index. +// Bulk insert releases into ElasticSearch index. function populate_indexes($table, $max) { $allowedIndexes = ['releases', 'predb']; diff --git a/misc/manticoresearch/optimize.php b/misc/manticoresearch/optimize.php index 2ec9a2a29..6db9cc833 100644 --- a/misc/manticoresearch/optimize.php +++ b/misc/manticoresearch/optimize.php @@ -2,10 +2,10 @@ require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; -use Blacklight\SphinxSearch; +use Blacklight\ManticoreSearch; try { - (new SphinxSearch())->optimizeRTIndex(); + (new ManticoreSearch())->optimizeRTIndex(); } catch (Exception $e) { echo $e->getMessage(); } diff --git a/misc/manticoresearch/populate_rt_indexes.php b/misc/manticoresearch/populate_rt_indexes.php index ab26393de..98a1544cf 100644 --- a/misc/manticoresearch/populate_rt_indexes.php +++ b/misc/manticoresearch/populate_rt_indexes.php @@ -4,7 +4,7 @@ require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use App\Models\Predb; use App\Models\Release; -use Blacklight\SphinxSearch; +use Blacklight\ManticoreSearch; use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; @@ -21,13 +21,13 @@ if (! isset($argv[1])) { populate_rt($argv[1], (isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : 10000)); -// Bulk insert releases into sphinx RT index. +// Bulk insert releases into Manticore RT index. function populate_rt($table, $max) { $allowedIndexes = ['releases_rt', 'predb_rt']; if (\in_array($table, $allowedIndexes, true)) { - $sphinx = new SphinxSearch(); - $sphinx->truncateRTIndex(Arr::wrap($table)); + $manticore = new ManticoreSearch(); + $manticore->truncateRTIndex(Arr::wrap($table)); if ($table === 'releases_rt') { DB::statement('SET SESSION group_concat_max_len=16384;'); $query = 'SELECT r.id, r.name, r.searchname, r.fromname, r.categories_id, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename @@ -77,7 +77,7 @@ function populate_rt($table, $max) } switch ($table) { case 'releases_rt': - $sphinx->insertRelease([ + $manticore->insertRelease([ 'id' => $row->id, 'name' => $row->name, 'searchname' => $row->searchname, @@ -88,7 +88,7 @@ function populate_rt($table, $max) break; case 'predb_rt': - $sphinx->insertPredb([ + $manticore->insertPredb([ 'id' => $row->id, 'title' => $row->title, 'filename' => $row->filename, diff --git a/misc/testing/Dev/test-ReleaseCleaner.php b/misc/testing/Dev/test-ReleaseCleaner.php index cb03e53d2..0ffb74ba9 100755 --- a/misc/testing/Dev/test-ReleaseCleaner.php +++ b/misc/testing/Dev/test-ReleaseCleaner.php @@ -5,7 +5,7 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use App\Models\Release; use App\Models\UsenetGroup; use Blacklight\ReleaseCleaning; -use Blacklight\SphinxSearch; +use Blacklight\ManticoreSearch; $message = 'Shows old searchname vs new searchname for releases in a group using the releaseCleaning class. (Good for testing new regex)'. @@ -52,7 +52,7 @@ if (\count($releases) === 0) { } $releaseCleaner = new ReleaseCleaning(); -$sphinx = new SphinxSearch(); +$manticore = new ManticoreSearch(); foreach ($releases as $release) { echo '.'; @@ -66,7 +66,7 @@ foreach ($releases as $release) { if ($rename === true) { Release::query()->where('id', '=', $release->id)->update(['searchname' => $newName]); - $sphinx->updateRelease($release->id); + $manticore->updateRelease($release->id); } } }