Ejemplo n.º 1
0
        public virtual async Task <IndexingResult> RemoveAsync(string documentType, IList <IndexDocument> documents)
        {
            var providerDocuments = documents.Select(d => new SearchDocument {
                Id = d.Id
            }).ToArray();

            var indexName      = GetIndexName(documentType);
            var bulkDefinition = new BulkDescriptor();

            bulkDefinition.DeleteMany(providerDocuments).Index(indexName).Type(documentType);

            var bulkResponse = await Client.BulkAsync(bulkDefinition);

            await Client.RefreshAsync(indexName);

            var result = new IndexingResult
            {
                Items = bulkResponse.Items.Select(i => new IndexingResultItem
                {
                    Id           = i.Id,
                    Succeeded    = i.IsValid,
                    ErrorMessage = i.Error?.Reason,
                }).ToArray(),
            };

            return(result);
        }
Ejemplo n.º 2
0
        public void RecordChanges(INestedAspect compareTo, BulkDescriptor bulk)
        {
            var correlation = byLocalName.CorrelateWith((compareTo as VariableSet)?.byLocalName);

            bulk.IndexMany(
                correlation.SourceItems.Where(t => t.Item.IsChanged(t.PairedWith)).Select(t => t.Item),
                (d, v) => d.Index(Constants.ControlIndex).Document(v));

            bulk.DeleteMany(
                correlation.NonSourceItems.Select(v => v.Item),
                (d, v) => d.Index(Constants.ControlIndex).Id(v.Id));
        }
Ejemplo n.º 3
0
        public void BulkIndexTest()
        {
            var objs = new[]
            {
                new Variable {
                    PackageId = "pack", Name = "name1"
                },
                new Variable {
                    PackageId = "pack", Name = "name2"
                },
                new Variable {
                    PackageId = "pack", Name = "name3"
                },
                new Variable {
                    PackageId = "pack", Name = "name4"
                },
                new Variable {
                    PackageId = "pack2", Name = "black"
                }
            };

            var bulk = new BulkDescriptor();

            bulk.IndexMany(objs,
                           (d, v) => d
                           .Index("test")
                           //.Type("variable")
                           .Document(v));

            var objs2 = new[]
            {
                new Variable {
                    PackageId = "pack4", Name = "name1"
                },
                new Variable {
                    PackageId = "pack4", Name = "name2"
                },
            };

            bulk.IndexMany(objs2,
                           (d, v) => d
                           .Index("test")
                           //.Type("variable")
                           .Document(v));

            bulk.DeleteMany(new Variable[0], (d, v) => d.Index("test").Id("1"));

            client.Bulk(bulk);
        }
Ejemplo n.º 4
0
 public void RemoveAll(BulkDescriptor bulk)
 {
     bulk.DeleteMany(
         byLocalName.Values,
         (d, v) => d.Index(Constants.ControlIndex).Id(v.Id));
 }