Fix movie and tv searches

This commit is contained in:
DariusIII
2026-04-23 00:18:36 +02:00
parent e18d92fe79
commit 95436c8b09
3 changed files with 164 additions and 0 deletions
@@ -1636,6 +1636,16 @@ class ReleaseSearchService
$query->where($field, 'LIKE', '%'.$term.'%');
}
}
if ($field === 'searchname' && count($terms) > 1) {
$normalizedPhrase = $this->normalizeMysqlFallbackPhrase($value);
if ($normalizedPhrase !== '') {
$query->whereRaw(
"LOWER(REPLACE(REPLACE(REPLACE($field, '.', ' '), '-', ' '), '_', ' ')) LIKE ?",
[$normalizedPhrase.'%']
);
}
}
}
}
@@ -1655,6 +1665,15 @@ class ReleaseSearchService
}
}
private function normalizeMysqlFallbackPhrase(string $value): string
{
$normalized = strtolower(trim($value));
$normalized = str_replace(['.', '-', '_'], ' ', $normalized);
$normalized = preg_replace('/\s+/', ' ', $normalized);
return trim((string) $normalized);
}
/**
* @param array<string, mixed> $siteIdArr
*/