File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Feature ;
4+
5+ use Tests \TestCase ;
6+ use Typesense \Exceptions \RequestMalformed ;
7+
8+ class MultiSearchTest extends TestCase
9+ {
10+ private $ searchRequests = [
11+ 'searches ' => [
12+ [
13+ 'q ' => 'book 1 ' ,
14+ ],
15+ [
16+ 'q ' => 'book 2 '
17+ ]
18+ ]
19+ ];
20+ private $ commonSearchParams = [
21+ 'query_by ' => 'title ' ,
22+ 'collection ' => 'books ' ,
23+ ];
24+
25+ protected function setUp (): void
26+ {
27+ parent ::setUp ();
28+
29+ $ this ->setUpCollection ('books ' );
30+ $ this ->setUpDocuments ('books ' );
31+ }
32+
33+ public function testCanPerformAMultiSearch (): void
34+ {
35+ $ returnData = $ this ->client ()->multiSearch ->perform ($ this ->searchRequests , $ this ->commonSearchParams );
36+ $ this ->assertEquals (2 , count ($ returnData ['results ' ]));
37+ }
38+
39+ public function testCanLimitNumberOfRequestsInOneMultiSearch (): void
40+ {
41+ $ searchRequests = [
42+ 'searches ' => [
43+ ...$ this ->searchRequests ['searches ' ],
44+ [
45+ 'q ' => 'book 3 '
46+ ]
47+ ]
48+ ];
49+
50+ $ this ->expectException (RequestMalformed::class);
51+ $ this ->client ()->multiSearch ->perform ($ searchRequests , [
52+ "limit_multi_searches " => 2 ,
53+ ...$ this ->commonSearchParams
54+ ]);
55+ }
56+ }
You can’t perform that action at this time.
0 commit comments