I'm in the process of moving my company's application from neo4j 3.5 to 4.0, and I saw that with neo4j 4.0 cypher finally supports subqueries. This is great news, since this feature is long overdue. It's very difficult to write complex queries without subqueries, and previously APOC procedures have been required in lieu of actual subqueries.
However reading the docs, I see the following:
- A subquery cannot refer to variables from the enclosing query.
This seriously limits the usefulness of subqueries. APOC subqueries can be passed parameters, so they remain strictly more powerful than standard cypher subqueries.
Then I read further and see:
A correlated subquery is a subquery that uses variables defined outside of the
Okay great, sounds exactly like what I want. But then:
This functionality is currently only available in Neo4j Fabric. Find out more about this feature in Operations Manual → Fabric.
My understanding is that Neo4j Fabric is a way to shard data into different databases. What does that have to do with passing parameters to a subquery? I can't think of any connection. It's not like people using a single database don't have a use for subqueries.
I'm really interested to hear from someone who works for neo on these design decisions, because from the outside it's totally insane. Including subqueries without parameters is like including functions without arguments in a programming language. It misses the point entirely about why this kind of feature is useful.