Add mysql fallback search switch, default is false

This commit is contained in:
DariusIII
2025-12-22 13:47:03 +01:00
parent 68c7d0eaec
commit 99250460f6
2 changed files with 19 additions and 14 deletions
+18 -14
View File
@@ -168,8 +168,8 @@ class ReleaseSearchService
}
}
// Fall back to MySQL if both Elasticsearch and Manticore failed
if (empty($searchResult)) {
// Fall back to MySQL if both Elasticsearch and Manticore failed (only if enabled)
if (empty($searchResult) && config('nntmux.mysql_search_fallback', false) === true) {
if (config('app.debug')) {
Log::debug('apiSearch: Falling back to MySQL search');
}
@@ -380,8 +380,8 @@ class ReleaseSearchService
}
}
// Fall back to MySQL if both Elasticsearch and Manticore failed
if (empty($searchResult)) {
// Fall back to MySQL if both Elasticsearch and Manticore failed (only if enabled)
if (empty($searchResult) && config('nntmux.mysql_search_fallback', false) === true) {
$searchResult = $this->performMySQLSearch(['searchname' => $searchName], $limit);
}
@@ -529,8 +529,8 @@ class ReleaseSearchService
}
}
// Fall back to MySQL if both Elasticsearch and Manticore failed
if (empty($searchResult)) {
// Fall back to MySQL if both Elasticsearch and Manticore failed (only if enabled)
if (empty($searchResult) && config('nntmux.mysql_search_fallback', false) === true) {
$searchResult = $this->performMySQLSearch(['searchname' => $name], $limit);
}
@@ -601,8 +601,8 @@ class ReleaseSearchService
}
}
// Fall back to MySQL if both Elasticsearch and Manticore failed
if (empty($searchResult)) {
// Fall back to MySQL if both Elasticsearch and Manticore failed (only if enabled)
if (empty($searchResult) && config('nntmux.mysql_search_fallback', false) === true) {
$searchResult = $this->performMySQLSearch(['searchname' => $name], $limit);
}
@@ -679,8 +679,8 @@ class ReleaseSearchService
}
}
// Fall back to MySQL if both Elasticsearch and Manticore failed
if (empty($searchResult)) {
// Fall back to MySQL if both Elasticsearch and Manticore failed (only if enabled)
if (empty($searchResult) && config('nntmux.mysql_search_fallback', false) === true) {
$searchResult = $this->performMySQLSearch(['searchname' => $name], $limit);
}
@@ -874,12 +874,16 @@ class ReleaseSearchService
return Arr::wrap(Arr::get($searchResult, 'id'));
}
// Fallback to MySQL LIKE search when both Elasticsearch and Manticore are unavailable
if (config('app.debug')) {
Log::debug('performIndexSearch: Falling back to MySQL search');
// Fallback to MySQL LIKE search when both Elasticsearch and Manticore are unavailable (only if enabled)
if (config('nntmux.mysql_search_fallback', false) === true) {
if (config('app.debug')) {
Log::debug('performIndexSearch: Falling back to MySQL search');
}
return $this->performMySQLSearch($searchFields, $limit);
}
return $this->performMySQLSearch($searchFields, $limit);
return [];
}
/**
+1
View File
@@ -20,6 +20,7 @@ return [
'purge_inactive_users' => env('PURGE_INACTIVE_USERS', false),
'purge_inactive_users_days' => env('PURGE_INACTIVE_USERS_DAYS', 180),
'elasticsearch_enabled' => env('ELASTICSEARCH_ENABLED', false),
'mysql_search_fallback' => env('MYSQL_SEARCH_FALLBACK', false), // Disable MySQL LIKE fallback when Manticore/Elasticsearch return no results
'btcpay_webhook_secret' => env('BTCPAY_SECRET'),
'tmp_unrar_path' => env('TEMP_UNRAR_PATH', storage_path('tmp/unrar/')),
'tmp_unzip_path' => env('TEMP_UNZIP_PATH', storage_path('tmp/unzip/')),