File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ Typesense uses [HTTPlug](http://httplug.io/) as an abstraction layer for an HTTP
2222
2323| Typesense Server | typesense-php |
2424| ------------------| ----------------|
25+ | \> = v0.19.0 | \> = v4.5.0 |
2526| \> = v0.18.0 | \> = v4.4.0 |
2627| \> = v0.17.0 | \> = v4.2.0 |
2728| \> = v0.16.0 | \> = v4.1.0 |
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ version: '3.5'
22
33services :
44 typesense :
5- image : typesense/typesense:0.18.0
5+ image : typesense/typesense:0.19.0.rc18
66 environment :
77 TYPESENSE_DATA_DIR : /data
88 TYPESENSE_API_KEY : xyz
Original file line number Diff line number Diff line change 159159 );
160160 echo "--------Search Document------- \n" ;
161161 echo "\n" ;
162+ echo "--------Multi search------- \n" ;
163+ print_r (
164+ $ client ->multiSearch ->perform (
165+ [
166+ 'searches ' => [
167+ [
168+ 'q ' => 'hunger ' ,
169+ 'sort_by ' => 'ratings_count:desc ' ,
170+ ],
171+ [
172+ 'q ' => 'game ' ,
173+ 'sort_by ' => 'ratings_count:asc ' ,
174+ ]
175+ ]
176+ ],
177+ [
178+ 'query_by ' => 'title ' ,
179+ 'collection ' => 'books '
180+ ]
181+ )
182+ );
183+ echo "--------Multi Search------- \n" ;
184+ echo "\n" ;
162185 echo "--------Delete Document------- \n" ;
163186 print_r ($ client ->collections ['books ' ]->documents ['1 ' ]->delete ());
164187 echo "--------Delete Document------- \n" ;
165188 echo "\n" ;
166189 echo "--------Import Documents------- \n" ;
167- $ docsToImport = [];
190+ $ docsToImport = [];
168191 $ exportedDocStrsArray = explode ('\n ' , $ exportedDocStrs );
169192 foreach ($ exportedDocStrsArray as $ exportedDocStr ) {
170193 $ docsToImport [] = json_decode ($ exportedDocStr , true );
Original file line number Diff line number Diff line change @@ -55,6 +55,11 @@ class Client
5555 */
5656 public Operations $ operations ;
5757
58+ /**
59+ * @var MultiSearch
60+ */
61+ public MultiSearch $ multiSearch ;
62+
5863 /**
5964 * @var ApiCall
6065 */
@@ -79,6 +84,7 @@ public function __construct(array $config)
7984 $ this ->metrics = new Metrics ($ this ->apiCall );
8085 $ this ->health = new Health ($ this ->apiCall );
8186 $ this ->operations = new Operations ($ this ->apiCall );
87+ $ this ->multiSearch = new MultiSearch ($ this ->apiCall );
8288 }
8389
8490 /**
@@ -136,4 +142,12 @@ public function getOperations(): Operations
136142 {
137143 return $ this ->operations ;
138144 }
145+
146+ /**
147+ * @return MultiSearch
148+ */
149+ public function getMultiSearch (): MultiSearch
150+ {
151+ return $ this ->multiSearch ;
152+ }
139153}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Typesense ;
4+
5+ use Http \Client \Exception as HttpClientException ;
6+ use Typesense \Exceptions \TypesenseClientError ;
7+
8+ /**
9+ * Class MultiSearch
10+ *
11+ * @package \Typesense
12+ */
13+ class MultiSearch
14+ {
15+ public const RESOURCE_PATH = '/multi_search ' ;
16+
17+ /**
18+ * @var ApiCall
19+ */
20+ private ApiCall $ apiCall ;
21+
22+ /**
23+ * Alias constructor.
24+ *
25+ * @param ApiCall $apiCall
26+ */
27+ public function __construct (ApiCall $ apiCall )
28+ {
29+ $ this ->apiCall = $ apiCall ;
30+ }
31+
32+ /**
33+ * @param string $searches
34+ * @param array $queryParameters
35+ *
36+ * @return array
37+ * @throws TypesenseClientError|HttpClientException
38+ */
39+ public function perform (array $ searches , array $ queryParameters = []): array
40+ {
41+ return $ this ->apiCall ->post (
42+ sprintf ('%s ' , static ::RESOURCE_PATH ),
43+ $ searches ,
44+ true ,
45+ $ queryParameters
46+ );
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments