Select Case When from ElasticSearch

Hello,
With this query I manage to build a graphic in Grafana, but connected to SQL Server:

"SELECT
access.time,
case when access.tiempo > 45000 or access.cod_status = 500 then 0 else 100 end as ‘Uptime’
FROM
access
WHERE
$__timeFilter(access.time) "

How can I get the same in Grafana but consulting ElasticSearch?

Please your help.