protected IndexResults GenerateAndIndex(int numMessages, int bufferSize) { //settings from http://benchmarks.elasticsearch.org/ var msgGenerator = new MessageGenerator(); var partitionedMessages = msgGenerator.Generate(numMessages).Partition(bufferSize); this.Client.CreateIndex(this.IndexName, c => c .Settings(s => s .NumberOfShards(6) .NumberOfReplicas(0) .RefreshInterval("30s") .Setting("refresh_interval", "30s") .Setting("index.store.type", "mmapfs") .Setting("index.store.throttle.type", "none") .Setting("indices.store.throttle.type", "none") .Setting("indices.memory.index_buffer_size", "10%") .Setting("index.translog.flush_threshold_size", "4g") .Setting("index.translog.flush_threshold_ops", 500000) .Setting("index.merge.scheduler.max_thread_count", 3) .Setting("index.merge.scheduler.max_merge_count", 6) ) .Mappings(m => m.Map <Message>(mm => mm.AutoMap())) ); var sw = Stopwatch.StartNew(); Interlocked.Exchange(ref NumSent, 0); Task <IBulkResponse>[] array = partitionedMessages .Select(messages => Client.IndexManyAsync(messages, this.IndexName) .ContinueWith(tt => { Interlocked.Add(ref NumSent, bufferSize); Console.Write("\r{2}: {0:0,0} msgs es-time: {1} ", NumSent, tt.Result.Took, this.Type); return(tt.Result); }) ).ToArray(); Task.WaitAll(array); sw.Stop(); Console.WriteLine(); Client.UpdateIndexSettings(this.IndexName, u => u .IndexSettings(i => i .RefreshInterval("1s") ) ); return(new IndexResults { Elapsed = sw.ElapsedMilliseconds, EsTimings = array.Select(a => a.Result.Took).ToList() }); }
protected IndexResults GenerateAndIndex(int numMessages, int bufferSize) { //settings from http://benchmarks.elasticsearch.org/ var msgGenerator = new MessageGenerator(); var partitionedMessages = msgGenerator.Generate(numMessages).Partition(bufferSize); this.Client.CreateIndex(this.IndexName, c => c .Settings(s => s .NumberOfShards(6) .NumberOfReplicas(0) .RefreshInterval("30s") .Setting("refresh_interval", "30s") .Setting("index.store.type", "mmapfs") .Setting("index.store.throttle.type", "none") .Setting("indices.store.throttle.type", "none") .Setting("indices.memory.index_buffer_size", "10%") .Setting("index.translog.flush_threshold_size", "4g") .Setting("index.translog.flush_threshold_ops", 500000) .Setting("index.merge.scheduler.max_thread_count", 3) .Setting("index.merge.scheduler.max_merge_count", 6) ) .Mappings(m => m.Map<Message>(mm => mm.AutoMap())) ); var sw = Stopwatch.StartNew(); Interlocked.Exchange(ref NumSent, 0); Task<IBulkResponse>[] array = partitionedMessages .Select(messages => Client.IndexManyAsync(messages, this.IndexName) .ContinueWith(tt => { Interlocked.Add(ref NumSent, bufferSize); Console.Write("\r{2}: {0:0,0} msgs es-time: {1} ", NumSent, tt.Result.Took, this.Type); return tt.Result; }) ).ToArray(); Task.WaitAll(array); sw.Stop(); Console.WriteLine(); Client.UpdateIndexSettings(this.IndexName, u => u .IndexSettings(i => i .RefreshInterval("1s") ) ); return new IndexResults { Elapsed = sw.ElapsedMilliseconds, EsTimings = array.Select(a => a.Result.Took).ToList() }; }