toBoolean
Generic Description
Is the long-form boolean conversion alias. It is documented separately because explicit type boundaries prevent planner tools from inventing hidden coercions for document-style values.
Simple example:
RETURN toBoolean('true') AS value
Consumer-Level Explanation
Use it when fully spelled conversion names make request contracts easier to read. Prefer this function when the input shape is mixed or imported and the query must state the intended type before comparison or aggregation.
More Detailed Explanation
toBoolean makes value shape explicit in Cypher. It is most useful around ingestion, document payloads, and assistant-generated queries where the planner should see the intended type boundary rather than relying on hidden client conversion.
Advanced Example
This example applies toBoolean at the point where a semi-structured value enters typed query logic, making the conversion boundary explicit.
WITH ['true', 'false', 'true'] AS raw_flags
UNWIND raw_flags AS raw_flag
RETURN raw_flag, toBoolean(raw_flag) AS active_flag
ORDER BY raw_flag
Real Use Cases
- normalizing imported CSV or document fields before comparison
- guarding mixed payloads before list, map, or numeric operations
- making assistant-authored query contracts explicit and reviewable
Real Limitations And Tradeoffs
- conversion only works when the input can be interpreted unambiguously
- heavy conversion inside analytical queries can hide ingestion contract problems
- type checks describe runtime values, not full schema validation