toFloat

Generic Description

Converts integers or parseable strings to floating-point values. It is documented separately because explicit type boundaries prevent planner tools from inventing hidden coercions for document-style values.

Simple example:

RETURN toFloat('42.5') AS value

Consumer-Level Explanation

Use it before scoring formulas where fractional arithmetic matters. 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

toFloat 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 toFloat at the point where a semi-structured value enters typed query logic, making the conversion boundary explicit.

WITH ['0.91', '0.76', '0.84'] AS raw_scores
UNWIND raw_scores AS raw_score
RETURN raw_score, toFloat(raw_score) AS score_float
ORDER BY score_float DESC

Real Use Cases

Real Limitations And Tradeoffs