public void Insert(int numberOfDocuments) { logger.Info($"Starting periodic bulk insertion with interval of {intervalInSecondes} seconds"); while (true) { var listDocument = documentGenerator.GenerateDocuments(numberOfDocuments); logger.Info($"Indexing {numberOfDocuments} documents..."); BulkInsert(listDocument.Select(doc => doc.AsDictionary()).ToList(), index, type); IndexDocumentsCount += numberOfDocuments; Thread.Sleep(intervalInSecondes * 1000); } }
static void Main(string[] args) { Console.CancelKeyPress += new ConsoleCancelEventHandler(exitHandler); logger.Info("Retrieving document schema."); var documentSchema = new DocumentSchemaReader(@"F:\Dev\DotNet\Configs\schema_document.txt").GetDocumentSchema(); logger.Info("Document schema retrieved."); var documentGenerator = new RandomDocumentGenerator(documentSchema); var index = new Index(INDEX_NAME); var type = new DocumentType(DOCUMENT_TYPE); var listDocument = documentGenerator.GenerateDocuments(10); var continuousInserter = new ContinuousBulkInserter(new Uri(ES_NODE_URL), documentGenerator, index, type, 10); continuousInserter.Insert(1000); }