/// <summary> /// Log in {logIndex}/{logBulkType} the bulk serializedNewObject and metrics /// </summary> private void LogBulk(BulkResponse bulkResponse) { client.Index(LogIndex, BulkLogType, new { success = bulkResponse.Success, httpStatusCode = bulkResponse.HttpStatusCode, documentsIndexed = bulkResponse.AffectedDocuments, startedOn = bulkResponse.StartedOn, duration = bulkResponse.Duration + "ms", exception = bulkResponse.ESexception != null ? ((Exception)bulkResponse.ESexception).Message : null }); }
private BulkResponse BulkProcess( Dictionary<object, Dictionary<string, object>> data, Func<string, string, object, Dictionary<string, object>, string> getPartialBulk) { stopwatch.Start(); string partialbulk = string.Empty; var bulkStartedOn = DateTime.UtcNow; //build bulk data foreach (var bulkData in data) partialbulk = partialbulk + getPartialBulk(_config._Index, _config._Type, bulkData.Key, bulkData.Value); var response = client.Bulk(partialbulk); stopwatch.Stop(); var bulkResponse = new BulkResponse { Success = response.Success, HttpStatusCode = response.HttpStatusCode, AffectedDocuments = response.Response["items"].HasValue ? ((object[])response.Response["items"].Value).Length : 0, ESexception = response.OriginalException, StartedOn = bulkStartedOn, Duration = stopwatch.ElapsedMilliseconds }; LogBulk(bulkResponse); stopwatch.Reset(); return bulkResponse; }