public void ShouldReturnDocumentTypesFromConfigurationForMappedObjectType() { var clientFactory = new ElasticsearchClientFactory(ElasticsearchConfiguration.Instance, false); clientFactory.GetDocumentNameForType(typeof(ApprenticeshipSummary)).Should().Be("apprenticeship"); clientFactory.GetDocumentNameForType(typeof(TraineeshipSummary)).Should().Be("traineeship"); clientFactory.GetDocumentNameForType(typeof(TestMappingClass)).Should().Be("test_mapping_class"); }
static void Main(string[] args) { var scroll = args[0]; var size = int.Parse(args[1]); Console.WriteLine("Scroll: {0}, Size {1}", scroll, size); var clientFactory = new ElasticsearchClientFactory(ElasticsearchConfiguration.Instance, false); var client = clientFactory.GetElasticClient(); Console.WriteLine("Connected. Press any key to start"); Console.ReadKey(); var indexName = clientFactory.GetIndexNameForType(typeof(Elastic.Common.Entities.Address)); var documentTypeName = clientFactory.GetDocumentNameForType(typeof(Elastic.Common.Entities.Address)); var scanResults = client.Search <Elastic.Common.Entities.Address>(s => s .Index(indexName) .Type(documentTypeName) .From(0) .Size(size) .Filter(fd => fd.Not(fd2 => fd2.Exists(fd3 => fd3.PostcodeSearch))) .SearchType(SearchType.Scan) .Scroll(scroll) ); var scrolls = 0; var totalUpdates = 0; var results = client.Scroll <Elastic.Common.Entities.Address>(GetScrollSelector(scanResults, scroll)); while (results.Hits.Any()) { var updates = 0; var descriptor = new BulkDescriptor(); foreach (var address in results.Hits) { AddPostcodeSearch(address, descriptor); updates++; totalUpdates++; } client.Bulk(descriptor); Console.WriteLine("Bulk updated {0} addresses. {1} addresses updated so far", updates, totalUpdates); results = client.Scroll <Elastic.Common.Entities.Address>(GetScrollSelector(results, scroll)); scrolls++; Console.WriteLine("Updated batch {0}", scrolls); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }