Exemplo n.º 1
0
        public void Execute(IESIndex <Offer> context)
        {
            var toDelete = this.actions.Where(x => x.Action == CRUDActionType.Delete).Select(x => (ESOffer)x.Entity).ToList();
            var toCreate = this.actions.Where(x => x.Action == CRUDActionType.Create).Select(x => (ESOffer)x.Entity).ToList();

            Console.WriteLine("OFFER BATCH CREATE:" + toCreate.Count());

            var toUpdate = this.actions.Where(x => x.Action == CRUDActionType.Update).Select(x => (ESOffer)x.Entity).ToList();

            var client = context.GetClient();
            var result = client.Bulk(x => {
                if (toCreate.Any())
                {
                    x = x.IndexMany(toCreate, (a, b) => { return(a.Id(b.Id)); });
                }

                if (toUpdate.Any())
                {
                    x = x.UpdateMany(toUpdate, (a, b) => { return(a.Id(b.Id)); });
                }

                if (toDelete.Any())
                {
                    x = x.DeleteMany(toDelete, (a, b) => { return(a.Id(b.Id)); });
                }

                return(x);
            });

            if (!result.IsValid)
            {
                Console.WriteLine("OFFER BATCH ERROR:" + result.DebugInformation);
                return;
            }
        }
Exemplo n.º 2
0
        public void Execute(IESIndex <Employee> context)
        {
            var toDelete = this.actions.Where(x => x.Action == CRUDActionType.Delete).Select(x => (ESEmployee)x.Entity).ToList();
            var toCreate = this.actions.Where(x => x.Action == CRUDActionType.Create).Select(x => (ESEmployee)x.Entity).ToList();
            var toUpdate = this.actions.Where(x => x.Action == CRUDActionType.Update).Select(x => (ESEmployee)x.Entity).ToList();

            var client = context.GetClient();
            var result = client.Bulk(x => {
                if (toCreate.Any())
                {
                    x = x.IndexMany(toCreate, (a, b) => { return(a.Id(b.Id)); });
                }

                if (toUpdate.Any())
                {
                    x = x.IndexMany(toUpdate, (a, b) => { return(a.Id(b.Id)); });
                }

                if (toDelete.Any())
                {
                    x = x.DeleteMany(toDelete, (a, b) => { return(a.Id(b.Id)); });
                }

                return(x);
            });

            if (!result.IsValid)
            {
                this.AddErrors(new QueryExectutionFailedError(result.DebugInformation));
            }
        }
        public void Execute(IESIndex <Offer> context)
        {
            var client         = context.GetClient();
            var searchResponse = client.Search <ESOffer>(s => s
                                                         .From(page)
                                                         .Size(size)
                                                         .Query(q => q
                                                                .Percolate(p => p
                                                                           .Field(f => f.Query)
                                                                           .Document(employee)
                                                                           )
                                                                )
                                                         );

            if (!searchResponse.IsValid)
            {
                this.AddErrors(new QueryExectutionFailedError(searchResponse.DebugInformation));
                return;
            }

            var offers = new List <Offer>();

            foreach (var doc in searchResponse.Documents)
            {
                offers.Add(doc);
            }

            SetValue(offers);
        }
Exemplo n.º 4
0
        public void Execute(IESIndex <Employee> context)
        {
            var client         = context.GetClient();
            var searchResponse = client.Search <ESEmployee>(s => s
                                                            .From(page)
                                                            .Size(size)
                                                            .Query(q => q
                                                                   .MultiMatch(mp => mp
                                                                               .Query(search)
                                                                               .Fields(f => f
                                                                                       .Fields(f1 => f1.Name, f2 => f2.JobTitle))))

                                                            );

            if (!searchResponse.IsValid)
            {
                this.AddErrors(new QueryExectutionFailedError(searchResponse.DebugInformation));
                return;
            }

            var employees = new List <Employee>();

            foreach (var doc in searchResponse.Documents)
            {
                employees.Add(doc);
            }

            SetValue(employees);
        }
        public void Execute(IESIndex <Employee> context)
        {
            var client = context.GetClient();
            var query  = new QueryContainer();

            foreach (var skill in offer.RequaredSkills)
            {
                query &= new MatchQuery {
                    Field = new Field("skills.id"),
                    Query = skill.Id.ToString()
                };
            }
            var searchResponse = client.Search <ESEmployee>(s => s
                                                            .From(page)
                                                            .Size(size)
                                                            .Query(q => query)
                                                            );

            if (!searchResponse.IsValid)
            {
                this.AddErrors(new QueryExectutionFailedError(searchResponse.DebugInformation));
                return;
            }

            var employees = new List <Employee>();

            foreach (var doc in searchResponse.Documents)
            {
                employees.Add(doc);
            }

            SetValue(employees);
        }
        public void Execute(IESIndex <Employee> context)
        {
            var toDelete = this.actions.Where(x => x.Action == CRUDActionType.Delete).Select(x => x.Entity).ToList();
            var toCreate = this.actions.Where(x => x.Action == CRUDActionType.Create).Select(x => x.Entity).ToList();
            var toUpdate = this.actions.Where(x => x.Action == CRUDActionType.Update).Select(x => x.Entity).ToList();

            var client = context.GetClient();

            client.Bulk(x => x.IndexMany(toCreate, (a, b) => { return(a.Id(b.Id)); })
                        .UpdateMany(toUpdate, (a, b) => { return(a.Id(b.Id)); })
                        .DeleteMany(toDelete, (a, b) => { return(a.Id(b.Id)); }));
        }
Exemplo n.º 7
0
        public void Execute(IESIndex <Offer> context)
        {
            var client   = context.GetClient();
            var response = client.Search <ESOffer>(s => s
                                                   .From(0)
                                                   .Size(0)
                                                   .Query(q => q
                                                          .MatchAll())
                                                   );

            if (!response.IsValid)
            {
                this.AddErrors(new QueryExectutionFailedError(response.DebugInformation));
                return;
            }

            this.SetValue(response.Total);
        }
        public void Execute(IESIndex <Employee> context)
        {
            var client   = context.GetClient();
            var response = client.Search <ESEmployee>(s => s
                                                      .Aggregations(a => a.Terms("skills", t => t.Field(p => p.Skills.First().Id))));

            if (!response.IsValid)
            {
                this.AddErrors(new QueryExectutionFailedError(response.DebugInformation));
                return;
            }

            var skills = response.Aggregations.Terms("skills");
            var result = new Dictionary <string, long>();

            foreach (var item in skills.Buckets)
            {
                result.Add(item.Key, item.DocCount.GetValueOrDefault());
            }

            this.SetValue(result);
        }