@@ -38,10 +38,10 @@ class UnifiedSearchController extends Controller
3838 parameters: [
3939 new OA \Parameter (
4040 name: 'filter[query] ' ,
41- description: 'Search query (minimum 3 characters). Searches names, class names, and other identifiers. ' ,
41+ description: 'Search query (minimum 2 characters). Searches names, class names, and other identifiers. ' ,
4242 in: 'query ' ,
4343 required: true ,
44- schema: new OA \Schema (type: 'string ' , minLength: 3 , example: 'Carrack ' ),
44+ schema: new OA \Schema (type: 'string ' , minLength: 2 , example: 'Carrack ' ),
4545 examples: [
4646 new OA \Examples (example: 'ship_search ' , summary: 'Search for a ship ' , value: 'carrack ' ),
4747 new OA \Examples (example: 'item_search ' , summary: 'Search for an item ' , value: 'arrow ' ),
@@ -105,7 +105,7 @@ class UnifiedSearchController extends Controller
105105 public function search (Request $ request ): JsonResponse
106106 {
107107 $ validated = $ request ->validate ([
108- 'filter.query ' => ['required ' , 'string ' , 'min:3 ' , 'max:64 ' , 'regex:/^[\pL\pN\s._-]+$/u ' ],
108+ 'filter.query ' => ['required ' , 'string ' , 'min:2 ' , 'max:64 ' , 'regex:/^[\pL\pN\s._-]+$/u ' ],
109109 ]);
110110
111111 $ query = $ validated ['filter ' ]['query ' ];
@@ -118,9 +118,11 @@ public function search(Request $request): JsonResponse
118118 |> mb_strtolower (...)
119119 |> sha1 (...),
120120 now ()->addSeconds (self ::SEARCH_CACHE_TTL_SECONDS ),
121- fn (): array => DB ::select ($ this ->buildSearchSql (), $ this ->buildSearchBindings ($ versionId , $ like )),
121+ fn (): array => array_map ( static fn ( $ r ) => ( array ) $ r , DB ::select ($ this ->buildSearchSql (), $ this ->buildSearchBindings ($ versionId , $ like) )),
122122 );
123123
124+ $ rows = array_map (static fn ($ r ) => (object ) $ r , $ rows );
125+
124126 $ grouped = collect ($ rows )
125127 ->groupBy ('type ' )
126128 ->map (fn ($ items , string $ type ) => [
0 commit comments