I'm trying to create a JSON-stype output of sport teams from different leagues. The problem I'm having is that the leagues are of varying depths. For example...
- English Premier League: League > team
- WNBA: League > conference > team
- NBA: League > conference > division > team
- NCAA American football: All of the above at the same time
I can create a query for a league with a fixed number of levels, such as the EPL or NBA, but I'm stuck on leagues like collegiate American football (NCAA FBS), where team nodes are 0, 1, or 2 levels deep. I attached a few files that might help understand the problem:
- A json file with a simplified version of the desired output (7.0 KB)
A cypher file to create a simplified version of the database (5.6 KB)
- I also created this as a temporary neo4j sandbox, if that's easier
- Cypher queries to show what I've been able to do so far:
If this were python or something I could use a loop, but how can I do something similar in native cypher? I know I can't use a recursive query, so perhaps a
UNION ALL with 3 subqueries, one for each level? Or using an apoc.case statement?
- neo4j version: browser with APOC