@@ -111,9 +111,20 @@ public function searchUsingApi($query, array $options = []): array
111111 ->join (', ' ) ?: '* ' ;
112112 }
113113
114- $ searchResults = config ('statamic-typesense.use_multi_search ' , false )
115- ? $ this ->multiSearch ($ options )
116- : $ this ->regularSearch ($ options );
114+ $ this ->getOrCreateIndex ();
115+
116+ // Using POST multiSearch to avoid potential request size limitations
117+ // (regular search uses GET and is limited in size by Typesense)
118+ $ searchRequest = [
119+ 'searches ' => [
120+ array_merge ($ options , [
121+ 'collection ' => $ this ->name
122+ ])
123+ ],
124+ ];
125+
126+ $ searchResults = $ this ->client ->multiSearch ->perform ($ searchRequest , []);
127+ $ searchResults = array_shift ($ searchResults ['results ' ]);
117128
118129 $ total = count ($ searchResults ['hits ' ]);
119130
@@ -184,26 +195,4 @@ public function client()
184195 {
185196 return $ this ->client ;
186197 }
187-
188- private function regularSearch (array $ options )
189- {
190- return $ this ->getOrCreateIndex ()->documents ->search ($ options );
191- }
192-
193- private function multiSearch (array $ options )
194- {
195- $ this ->getOrCreateIndex ();
196-
197- $ searchRequest = [
198- 'searches ' => [
199- array_merge ($ options , [
200- 'collection ' => $ this ->name
201- ])
202- ],
203- ];
204-
205- $ multiSearchResults = $ this ->client ->multiSearch ->perform ($ searchRequest , []);
206-
207- return array_shift ($ multiSearchResults ['results ' ]);
208- }
209198}
0 commit comments