Exemple #1
0
        public int RetornaTotalNoticias(ZRN.Promocoes.FiltroPromocaoNoticia filtro)
        {
            var node      = new Uri(_servidorElastic);
            var senttings = new ConnectionSettings(node);

            senttings.DisableDirectStreaming(true);
            senttings.DefaultIndex(_indiceElastic + "noticias");
            var client = new ElasticClient(senttings);

            var resp = client.Search <ZRN.PromocoesElastic.Noticia>(s => s
                                                                    .Type("noticias")
                                                                    .Query(q =>
                                                                           q.Term("promocoes.idpromocao", filtro.idPromocao) &&
                                                                           q.Term("empresas.idempresa", filtro.idEmpresa)
                                                                           &&
                                                                           (
                                                                               filtro.expressao != null && filtro.expressao != "" ?
                                                                               q.MultiMatch(m => m
                                                                                            .Fields(f => f.Field("conteudo")
                                                                                                    )
                                                                                            .Query(filtro.expressao)
                                                                                            .Operator(Operator.And)
                                                                                            ) : null
                                                                           )
                                                                           )
                                                                    );

            return(Convert.ToInt32(resp.Total));
        }
Exemple #2
0
        public List <ZRN.PromocoesElastic.Noticia> RetornaNoticias(ZRN.Promocoes.FiltroPromocaoNoticia filtro)
        {
            var node      = new Uri(_servidorElastic);
            var senttings = new ConnectionSettings(node);

            senttings.DisableDirectStreaming(true);
            senttings.DefaultIndex(_indiceElastic + "noticias");
            var client = new ElasticClient(senttings);

            var resp = client.Search <ZRN.PromocoesElastic.Noticia>(s => s
                                                                    .Type("noticias")
                                                                    .Query(q =>
                                                                           q.Term("promocoes.idpromocao", filtro.idPromocao) &&
                                                                           q.Term("empresas.idempresa", filtro.idEmpresa)
                                                                           &&
                                                                           (
                                                                               filtro.expressao != null && filtro.expressao != "" ?
                                                                               q.MultiMatch(m => m
                                                                                            .Fields(f => f.Field("conteudo")
                                                                                                    )
                                                                                            .Query(filtro.expressao)
                                                                                            .Operator(Operator.And)
                                                                                            ) : null
                                                                           )
                                                                           )
                                                                    );

            return(resp.Documents.OrderByDescending(x => x.datapublicacao).Skip(filtro.pagina).Take(filtro.qtdeRegistros).ToList());
        }
Exemple #3
0
        public int GetTotalNoticias(ZRN.Promocoes.FiltroPromocaoNoticia filtro)
        {
            var RN = new ZRN.Promocoes.PromocaoNoticias(Configuracoes.ServidorElastic, Configuracoes.IndexElastic);

            return(RN.RetornaTotalNoticias(filtro));
        }
Exemple #4
0
        public List <ZRN.PromocoesElastic.Noticia> GetNoticias(ZRN.Promocoes.FiltroPromocaoNoticia filtro)
        {
            var RN = new ZRN.Promocoes.PromocaoNoticias(Configuracoes.ServidorElastic, Configuracoes.IndexElastic);

            return(RN.RetornaNoticias(filtro));
        }