1- package service ;
1+ package main . java . service ;
22
33import javax .json .Json ;
44import javax .net .ssl .HttpsURLConnection ;
1313import java .util .Formatter ;
1414import java .util .function .Consumer ;
1515
16- /**
17- * This class is responsible for implementing HTTP operations for creating the index, uploading documents and searching the data*/
16+ /* This class is responsible for implementing HTTP operations for creating the index, uploading documents and searching the data*/
1817public class SearchServiceClient {
1918 private final String _adminKey ;
2019 private final String _queryKey ;
@@ -130,14 +129,15 @@ public boolean createIndex(String indexDefinitionFile) throws IOException, Inter
130129 "https://%s.search.windows.net/indexes/%s?api-version=%s" ,
131130 _serviceName ,_indexName ,_apiVersion ));
132131 //Read in index definition file
133- var inputStream = SearchServiceClient .class .getResourceAsStream ("index.json" );
132+ var inputStream = SearchServiceClient .class .getResourceAsStream (indexDefinitionFile );
134133 var indexDef = new String (inputStream .readAllBytes (), StandardCharsets .UTF_8 );
135134 //Send HTTP PUT request to create the index in the search service
136135 var request = httpRequest (uri , _adminKey , "PUT" , indexDef );
137136 var response = sendRequest (request );
138137 return isSuccessResponse (response );
139138 }
140139
140+
141141 public boolean uploadDocuments (String documentsFile ) throws IOException , InterruptedException {
142142 logMessage ("\n Uploading documents..." );
143143 //Build the search service URL
@@ -153,6 +153,7 @@ public boolean uploadDocuments(String documentsFile) throws IOException, Interru
153153 return isSuccessResponse (response );
154154 }
155155
156+
156157 public SearchOptions createSearchOptions () { return new SearchOptions ();}
157158
158159 //Defines available search parameters that can be set
@@ -211,4 +212,6 @@ public void searchPlus(String queryString, SearchOptions options) {
211212 }
212213
213214 }
215+
216+
214217}
0 commit comments