Exemple #1
0
 static void ImportFromJson(string IndexName)
 {
     try
     {
         foreach (string fileName in Directory.GetFiles("", IndexName + "*.json"))
         {
             Console.WriteLine("Uploading documents from file: {0}", fileName);
             string json = File.ReadAllText(fileName);
             Uri    uri  = new Uri(ServiceUri, "/indexes/" + IndexName + "/docs/index");
             HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(HttpClient, HttpMethod.Post, uri, json);
             response.EnsureSuccessStatusCode();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error: {0}", ex.Message.ToString());
     }
 }
Exemple #2
0
 private static void DeleteIndex(string IndexName)
 {
     try
     {
         try
         {
             Uri uri = new Uri(ServiceUri, "/indexes" + IndexName);
             HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(HttpClient, HttpMethod.Delete, uri);
             response.EnsureSuccessStatusCode();
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error: {0}", ex.Message.ToString());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error deleting index: {0}\r\n", ex.Message);
     }
 }