private static BulkRequest CreateIndexBulkRequest <T>(IEnumerable <T> objects, IndexName index, TypeName type) where T : class
        {
            @objects.ThrowIfEmpty(nameof(objects));
            var bulkRequest = new BulkRequest(index, type);
            var indexOps    = @objects
                              .Select(o => new BulkIndexOperation <T>(o))
                              .Cast <IBulkOperation>()
                              .ToList();

            bulkRequest.Operations = indexOps;
            return(bulkRequest);
        }
        private static BulkRequest CreateDeleteBulkRequest <T>(IEnumerable <T> objects, string index, string type) where T : class
        {
            @objects.ThrowIfEmpty(nameof(objects));
            var bulkRequest = new BulkRequest(index, type);
            var deletes     = @objects
                              .Select(o => new BulkDeleteOperation <T>(o))
                              .Cast <IBulkOperation>()
                              .ToList();

            bulkRequest.Operations = deletes;
            return(bulkRequest);
        }
        private static BulkRequest CreateIndexBulkRequest <T>(IEnumerable <T> objects, IndexName index) where T : class
        {
            var bulkRequest = new BulkRequest(index);
            var indexOps    = @objects
                              .NotEmpty(nameof(objects))
                              .Select(o => new BulkIndexOperation <T>(o))
                              .Cast <IBulkOperation>()
                              .ToList();

            bulkRequest.Operations = new BulkOperationsCollection <IBulkOperation>(indexOps);
            return(bulkRequest);
        }
Ejemplo n.º 4
0
        private static BulkRequest CreateIndexBulkRequest <T>(IEnumerable <T> objects, string index, string type) where T : class
        {
            @objects.ThrowIfEmpty("objects");
            var bulkRequest = new BulkRequest {
                Index = index, Type = type
            };
            var indexOps = @objects
                           .Select(o => new BulkIndexOperation <T>(o))
                           .Cast <IBulkOperation>()
                           .ToList();

            bulkRequest.Operations = indexOps;
            return(bulkRequest);
        }
Ejemplo n.º 5
0
        private static BulkRequest CreateDeleteBulkRequest <T>(IEnumerable <T> objects, IndexName index) where T : class
        {
            // ReSharper disable once PossibleMultipleEnumeration
            objects.ThrowIfEmpty(nameof(objects));
            var bulkRequest = new BulkRequest(index);
            // ReSharper disable once PossibleMultipleEnumeration
            var deletes = objects
                          .Select(o => new BulkDeleteOperation <T>(o))
                          .Cast <IBulkOperation>()
                          .ToList();

            bulkRequest.Operations = new BulkOperationsCollection <IBulkOperation>(deletes);

            return(bulkRequest);
        }