File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 129129 $ docsToImport [] = json_decode ($ exportedDocStr , true );
130130 }
131131 $ importRes =
132- $ client ->collections ['books ' ]->documents ->create_many ($ docsToImport );
132+ $ client ->collections ['books ' ]->documents ->createMany ($ docsToImport );
133133 print_r ($ importRes );
134134 echo "--------Import Documents------- \n" ;
135135 echo "\n" ;
Original file line number Diff line number Diff line change @@ -76,29 +76,24 @@ public function create(array $document): array
7676 * @return array
7777 * @throws \Typesence\Exceptions\TypesenseClientError|\GuzzleHttp\Exception\GuzzleException
7878 */
79- public function create_many (array $ documents ): array
79+ public function createMany (array $ documents ): array
8080 {
81- $ res = $ this ->import ($ documents );
81+ $ res = $ this ->import (implode ( "\n" , $ documents) );
8282 return array_map (static function ($ item ) {
8383 return json_decode ($ item , true );
8484 }, explode ("\n" , $ res ));
8585 }
8686
8787 /**
88- * @param array $documents
88+ * @param string $documents
8989 *
9090 * @return string
9191 * @throws \Typesence\Exceptions\TypesenseClientError
9292 * @throws \GuzzleHttp\Exception\GuzzleException
9393 */
94- public function import (array $ documents ): string
94+ public function import (string $ documents ): string
9595 {
96- $ documentsStr = [];
97- foreach ($ documents as $ document ) {
98- $ documentsStr [] = json_encode ($ document );
99- }
100- $ docsImport = implode ("\n" , $ documentsStr );
101- return $ this ->apiCall ->post ($ this ->endPointPath ('import ' ), $ docsImport , false );
96+ return $ this ->apiCall ->post ($ this ->endPointPath ('import ' ), $ documents , false );
10297 }
10398
10499 /**
You can’t perform that action at this time.
0 commit comments