rand

Generic Description

Returns a nondeterministic random floating-point value. It is documented separately because numeric transforms change ranking, thresholds, and buckets in ways planner tools must not guess.

Simple example:

RETURN rand() AS value

Consumer-Level Explanation

Use it for ad hoc sampling only, not for reproducible ranking or persisted business decisions. Prefer this function when the transformation is a deliberate part of the model or report, and name the derived value in a WITH stage when it will be reused.

More Detailed Explanation

rand is scalar math, so it is evaluated per row after graph patterns, procedure output, or map projections have produced values. Keep it close to the query when thresholds, ranking, and derived fields need to be auditable and reproducible.

Advanced Example

This example applies rand to a named score component after matching graph data, making the derived metric reviewable before ordering.

MATCH (d:Document)
WITH d, rand() AS sample_score
RETURN d.title AS document, sample_score
ORDER BY sample_score
LIMIT 2

Real Use Cases

Real Limitations And Tradeoffs