33import com .fasterxml .jackson .databind .ObjectMapper ;
44import org .typesense .model .*;
55
6- import java .util .ArrayList ;
7- import java .util .HashMap ;
6+ import java .util .Map ;
87
98public class Documents {
109
@@ -20,31 +19,31 @@ public class Documents {
2019 this .configuration = configuration ;
2120 }
2221
23- public HashMap <String , Object > create (HashMap <String , Object > document ) throws Exception {
24- return this .apiCall .post (getEndPoint ("/" ), document , null , HashMap .class );
22+ public Map <String , Object > create (Map <String , Object > document ) throws Exception {
23+ return this .apiCall .post (getEndPoint ("/" ), document , null , Map .class );
2524 }
2625
2726 public String create (String document ) throws Exception {
2827 return this .apiCall .post (getEndPoint ("/" ),document ,null ,String .class );
2928 }
3029
31- public String create (HashMap <String , Object > document , ImportDocumentsParameters queryParameters ) throws Exception {
30+ public String create (Map <String , Object > document , ImportDocumentsParameters queryParameters ) throws Exception {
3231 return this .apiCall .post (getEndPoint ("/" ),document ,queryParameters ,String .class );
3332 }
3433
35- public HashMap <String , Object > upsert (HashMap <String , Object > document ) throws Exception {
34+ public Map <String , Object > upsert (Map <String , Object > document ) throws Exception {
3635 ImportDocumentsParameters queryParameters = new ImportDocumentsParameters ();
3736 queryParameters .action ("upsert" );
3837
39- return this .apiCall .post (getEndPoint ("/" ),document ,queryParameters ,HashMap .class );
38+ return this .apiCall .post (getEndPoint ("/" ),document ,queryParameters ,Map .class );
4039 }
4140
4241 public SearchResult search (SearchParameters searchParameters ) throws Exception {
4342 return this .apiCall .get (getEndPoint ("search" ), searchParameters ,org .typesense .model .SearchResult .class );
4443 }
4544
46- public HashMap <String , Object > delete (DeleteDocumentsParameters queryParameters ) throws Exception {
47- return this .apiCall .delete (getEndPoint ("/" ), queryParameters , HashMap .class );
45+ public Map <String , Object > delete (DeleteDocumentsParameters queryParameters ) throws Exception {
46+ return this .apiCall .delete (getEndPoint ("/" ), queryParameters , Map .class );
4847 }
4948
5049 public String export () throws Exception {
@@ -59,11 +58,10 @@ public String import_(String document, ImportDocumentsParameters queryParameters
5958 return this .apiCall .post (this .getEndPoint ("import" ),document , queryParameters ,String .class );
6059 }
6160
62- public String import_ (ArrayList < HashMap <String , Object >> documents , ImportDocumentsParameters queryParameters ) throws Exception {
61+ public String import_ (java . util . Collection < Map <String , Object >> documents , ImportDocumentsParameters queryParameters ) throws Exception {
6362 ObjectMapper mapper = new ObjectMapper ();
6463 String json ="" ;
65- for (int i =0 ;i <documents .size ();i ++){
66- HashMap <String , Object > document = documents .get (i );
64+ for (Map <String , Object > document : documents ){
6765 try {
6866 //Convert Map to JSON
6967 json = json .concat (mapper .writeValueAsString (document ) + "\n " );
0 commit comments