public void SetUniqueNames(string languageCode, string countryCode = "all") { var duplicateLocations = _adoClientService.GetDuplicateLocations(languageCode, countryCode); if (duplicateLocations.Any()) { var service = new ElasticClientService(); var client = service.GetClient(); foreach (var location in duplicateLocations) { var result = client.Get <ElasticsearchLocation>(g => g.Index("locations-en-05.05.16.09.24.09").Type("location").Id(location.Id)); if (result.Found && result.Source != null && result.Source.Suggest != null && result.Source.Suggest.Output != null) { location.Name = result.Source.Suggest.Output; } } try { _adoClientService.SetDuplicateLocations(duplicateLocations, DataTableBuilder.GetLocationUniqueFormattedNameTable()); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); } } }
public void Analyze() { var processSelectedCountries = ConfigurationManager.AppSettings["ProcessSelectedCountries"]; var countryCodes = (processSelectedCountries.ToLower().Equals("true")) ? ConfigurationManager.AppSettings["Countries"].Split(',').ToList() : _adoClientService.GetCountryCodes(); if (countryCodes.Any()) { var service = new ElasticClientService(); var client = service.GetClient(); foreach (var countryCode in countryCodes) { Console.WriteLine(String.Format("--> Country being processed: {0}", countryCode)); var locationIds = _adoClientService.GetLocationIds(countryCode); var formattedNames = new List <LocationFormattedNamesAnalysis>(); if (locationIds.Any()) { foreach (var id in locationIds) { var result = client.Get <ElasticsearchLocation>(g => g.Index("locations-07.20.16.15.44.58").Type("location").Id(id)); if (result.Found && result.Source != null && result.Source.Suggest != null && result.Source.Suggest.Output != null) { formattedNames.Add(new LocationFormattedNamesAnalysis { ID = result.Source.Suggest.Payload.ID, CountryCode = result.Source.Suggest.Payload.CountryCode, LanguageCode = "en", FormattedName = result.Source.Suggest.Output, FormattedNameNon = result.Source.Suggest.Output, TypeId = result.Source.Suggest.Payload.TypeID, Formatting = 0 }); } } } try { _adoClientService.FormattedNameForAnalysis(formattedNames, DataTableBuilder.GetFormattedNamesAnalysisTable()); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); } } } }
public void Process() { List <Tuple <long, string, string> > missingLocations = new List <Tuple <long, string, string> >(); var cnt = 0; var countryCodes = _adoClientService.GetCountryCodes(); var client = _esClient.GetClient(); foreach (var countryCode in countryCodes) { Console.WriteLine("Processing: {0}", countryCode); var ids = _adoClientService.GetLocationIds(countryCode); Console.WriteLine("---> {0} locations to process.", ids.Count()); Console.WriteLine(" "); foreach (var id in ids) { var locationForLargerIndex = client.Get <ElasticsearchLocation>(g => g.Index("locations-en-08.29.16.13.25.30").Type("location").Id(id)); if (locationForLargerIndex != null && locationForLargerIndex.Source != null) { var locationForSmallerIndex = client.Get <ElasticsearchLocation>(g => g.Index("locations-en-08.29.16.11.52.46").Type("location").Id(id)); if (locationForSmallerIndex == null || locationForSmallerIndex.Source == null || locationForSmallerIndex.Source.ID != locationForLargerIndex.Source.ID) { cnt++; Console.WriteLine(string.Format("{0} : {1}, {2} -- {3}", cnt, locationForLargerIndex.Source.ID, locationForLargerIndex.Source.FormattedName, locationForLargerIndex.Source.CountryCode)); missingLocations.Add(new Tuple <long, string, string>(locationForLargerIndex.Source.ID, locationForLargerIndex.Source.FormattedName, locationForLargerIndex.Source.CountryCode)); } } } } Console.WriteLine("-----"); Console.WriteLine("Total number of locations: {0}.", cnt); Console.WriteLine("-----"); foreach (var location in missingLocations) { Console.WriteLine("{0}, {1} -- {2}", location.Item1, location.Item2, location.Item3); } Console.WriteLine("-----"); Console.WriteLine("Processing completed."); Console.ReadLine(); // Get all indexed locations from database. // Look for location in first index. // If found look for the location in the second index. // If not found increment counter and display location id and name. // when finished display count. }