From a55061bdfa7fab824fa946ff07c6834a9fe09163 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Sat, 3 Jan 2026 01:38:59 +0100 Subject: [PATCH] sadasd --- src/App/Search.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/App/Search.php b/src/App/Search.php index 17776db..93c49a0 100644 --- a/src/App/Search.php +++ b/src/App/Search.php @@ -26,13 +26,21 @@ final class Search foreach ($tokens as $tok) { $tok = trim($tok); if ($tok === '') continue; - $conditions[] = "(title LIKE CONCAT('%', ?, '%') OR teaser_public LIKE CONCAT('%', ?, '%') OR description LIKE CONCAT('%', ?, '%') OR city LIKE CONCAT('%', ?, '%') OR region LIKE CONCAT('%', ?, '%') OR zip LIKE CONCAT('%', ?, '%'))"; + // LIKE + phonetic (SOUNDEX) to allow partial and typo-tolerant matches + $conditions[] = "(title LIKE CONCAT('%', ?, '%') OR teaser_public LIKE CONCAT('%', ?, '%') OR description LIKE CONCAT('%', ?, '%') OR city LIKE CONCAT('%', ?, '%') OR region LIKE CONCAT('%', ?, '%') OR zip LIKE CONCAT('%', ?, '%') OR SOUNDEX(title)=SOUNDEX(?) OR SOUNDEX(teaser_public)=SOUNDEX(?) OR SOUNDEX(description)=SOUNDEX(?) OR SOUNDEX(city)=SOUNDEX(?) OR SOUNDEX(region)=SOUNDEX(?))"; + // LIKE bindings $bindTokens[] = $tok; $bindTokens[] = $tok; $bindTokens[] = $tok; $bindTokens[] = $tok; $bindTokens[] = $tok; $bindTokens[] = $tok; + // SOUNDEX bindings + $bindTokens[] = $tok; + $bindTokens[] = $tok; + $bindTokens[] = $tok; + $bindTokens[] = $tok; + $bindTokens[] = $tok; $i++; } @@ -41,7 +49,8 @@ final class Search "status != 'cancelled'", ]; if ($conditions) { - $whereParts[] = implode(' AND ', $conditions); + // "OR" so that partial matches across tokens are allowed + $whereParts[] = '(' . implode(' OR ', $conditions) . ')'; } $distanceFiltering = false; @@ -76,7 +85,7 @@ final class Search // Radius for HAVING $bind[] = $radius; } else { - $sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng, 30 AS distance_km"; + $sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng, 1 AS distance_km"; $bind = $bindTokens; }