`missing_ratio`

Generic Description

Estimates the fraction of expected grid slots that are missing observations. It is documented separately because time construction, sequence ordering, window parameters, and as-of behavior materially change analytical meaning.

Simple example:

WITH [{ts: 1735689600000, value: 10.0, state: 'ok'}, {ts: 1735689660000, value: 13.0, state: 'ok'}, {ts: 1735689840000, value: 9.0, state: 'warn'}, {ts: 1735690200000, value: 16.0, state: 'ok'}] AS readings
RETURN missing_ratio(readings, 60000) AS missing_ratio_value

Consumer-Level Explanation

Use it to judge whether a timeseries is dense enough for downstream analytics. Prefer this function when the temporal assumption should be visible to the planner, especially for event streams, freshness checks, and sequence features.

More Detailed Explanation

missing_ratio works on ordered temporal or sequence-style values inside Cypher. The practical contract is to assemble the sequence deliberately, choose the time or window parameter explicitly, and return named fields so downstream planner tooling does not invent unsupported window syntax.

Advanced Example

This example names the event stream and operational context before applying missing_ratio, which helps planner tooling preserve the intended sequence semantics.

WITH 'sensor-1' AS subject_id,
     [{ts: 1735689600000, value: 10.0, state: 'ok'}, {ts: 1735689660000, value: 13.0, state: 'ok'}, {ts: 1735689840000, value: 9.0, state: 'warn'}, {ts: 1735690200000, value: 16.0, state: 'ok'}] AS readings
RETURN subject_id,
       missing_ratio(readings, 60000) AS missing_ratio_value

Real Use Cases

Real Limitations And Tradeoffs