Hi there, I'm very new in Elastic world and I'm stuck with a simple query... How could I code in Kibana language the equivalent to this:
SELECT le.ID_Lote,
CASE WHEN
SUM (Case when le.ID_origem = 1 then 1 else 0 end) = SUM(Case when le.ID_origem = 3 AND ISNULL(Nr_Contrato,0) > 0 then 1 else 0 end) AND
SUM (Case when le.ID_origem = 1 then 1 else 0 end) = MAX(Qtd_lote)
THEN 'Green'
ELSE 'Red'
END as S_ESTEIRA,
SUM (Case when le.ID_origem = 5 AND ISNULL(Nr_Titulo,0) > 0 then 1 else 0 end) QTDE_SAIDA,
SUM (Case when le.ID_origem = 5 AND ISNULL(Nr_Titulo,0) > 0 then le.Vr_Transacao else 0 end) VALOR_SAIDA
FROM LogElastic le
GROUP BY ID_Lote
Considering my index is called: integracao.worker.logs.integracao-*
And my document structure is something like that:
origem: 5 idLote: 200 qtdLote: 2 nrProposta: 803 nrContrato: 10013 nrTitulo: 30005 vrTransacao:200