toBool

Generic Description

Converts booleans or true/false strings to boolean values. It is documented separately because explicit type boundaries prevent planner tools from inventing hidden coercions for document-style values.

Simple example:

RETURN toBool('true') AS value

Consumer-Level Explanation

Use it when source systems serialize flags as text but Cypher filtering should be typed. 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

toBool 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 toBool 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, toBool(raw_flag) AS active_flag
ORDER BY raw_flag

Real Use Cases

Real Limitations And Tradeoffs