public void UpdateBestBets(string indexName, Type indexType, string id, string[] terms) { if (terms == null || terms.Length == 0) { return; } var request = new BestBetsRequest(terms); var jsonSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var json = JsonConvert.SerializeObject(request, jsonSettings); var data = Encoding.UTF8.GetBytes(json); var uri = $"{_settings.Host}/{indexName}/{indexType.GetTypeName()}/{id}/_update"; Logger.Information("Update BestBets:\n" + JToken.Parse(json).ToString(Formatting.Indented)); _httpClientHelper.Post(new Uri(uri), data); if (AfterUpdateBestBet != null) { Logger.Debug("Firing subscribed event AfterUpdateBestBet"); AfterUpdateBestBet(new BestBetEventArgs { Index = indexName, Type = indexType, Id = id, Terms = terms }); } RefreshIndex(indexName); }
public void ClearBestBets(string indexName, Type indexType, string id) { var request = new BestBetsRequest(new string[0]); var jsonSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var json = JsonConvert.SerializeObject(request, jsonSettings); var data = Encoding.UTF8.GetBytes(json); var uri = $"{_settings.Host}/{indexName}/{indexType.GetTypeName()}/{id}/_update"; Logger.Information($"Clearing BestBets for id '{id}'"); _httpClientHelper.Post(new Uri(uri), data); if (AfterUpdateBestBet != null) { Logger.Debug("Firing subscribed event AfterUpdateBestBet"); AfterUpdateBestBet(new BestBetEventArgs { Index = indexName, Type = indexType, Id = id }); } }