Exported on 5/15/2025 at 23:49:54 PDT from Cursor (0.50.4)
User
section schema and properties from neo4j
Cursor
Here is the schema and properties for the Section node in your Neo4j database:
Node Label: Section
Relationships:
Properties found on Section nodes:
If you need details about the data types or want to see example values for any property, let me know!
User
find all parent, child, and linked to nodes of 10.6.4, follow the linked to nodes recursively, return id, clause, clauseNumber, requirement
Cursor
Here are all parent, child, and recursively “LINKS_TO” connected nodes for clauseNumber 10.6.4, with their id, clause, clauseNumber, and requirement:
id: c2927624-257b-4950-a7b8-95ee6dd0c2e3
id: b9cff05e-3172-4674-b40b-eafc271db74a
id: f66ecb66-5a33-4d91-a08b-8db0bd1a8c45
id: b24fbff1-a467-45df-8ae8-c7f9d0db2a57
id: 8b262467-2b9d-4dc7-8bd7-a93cefd7b962
If you need the full requirement text for any node or want to see the relationship paths, let me know!
User
MATCH (start:Section {clauseNumber: ‘10.6.4’})\nOPTIONAL MATCH (start)-[:PARENT_OF]->(parent:Section)\nOPTIONAL MATCH (start)-[:CHILD_OF]->(child:Section)\nOPTIONAL MATCH path=(start)-[:LINKS_TO*]->(linked:Section)\nWITH COLLECT(DISTINCT parent) AS parents, COLLECT(DISTINCT child) AS children, COLLECT(DISTINCT linked) AS linkedNodes, start\nUNWIND parents + children + linkedNodes + [start] AS node\nWITH DISTINCT node\nWHERE node IS NOT NULL\nRETURN node.id AS id, node.clause AS clause, node.clauseNumber AS clauseNumber, node.requirement AS requirement”
strip the newlines from this query so i can use it in my shell
Cursor
Here is your Cypher query with all newlines removed, so you can use it in your shell:
MATCH (start:Section {clauseNumber: '10.6.4'}) OPTIONAL MATCH (start)-[:PARENT_OF]->(parent:Section) OPTIONAL MATCH (start)-[:CHILD_OF]->(child:Section) OPTIONAL MATCH path=(start)-[:LINKS_TO*]->(linked:Section) WITH COLLECT(DISTINCT parent) AS parents, COLLECT(DISTINCT child) AS children, COLLECT(DISTINCT linked) AS linkedNodes, start UNWIND parents + children + linkedNodes + [start] AS node WITH DISTINCT node WHERE node IS NOT NULL RETURN node.id AS id, node.clause AS clause, node.clauseNumber AS clauseNumber, node.requirement AS requirement
You can copy and paste this directly into your shell or Neo4j browser.
MATCH (start:Section {clauseNumber: '10.6.4'}) OPTIONAL MATCH (start)-[:PARENT_OF]->(parent:Section) OPTIONAL MATCH (start)-[:CHILD_OF]->(child:Section) OPTIONAL MATCH path=(start)-[:LINKS_TO*]->(linked:Section) WITH COLLECT(DISTINCT parent) AS parents, COLLECT(DISTINCT child) AS children, COLLECT(DISTINCT linked) AS linkedNodes, start UNWIND parents + children + linkedNodes + [start] AS node WITH DISTINCT node WHERE node IS NOT NULL RETURN node.id AS id, node.clause AS clause, node.clauseNumber AS clauseNumber, node.requirement AS requirement
User
explain this query to me as someone who has only just started using neo4j
Cursor
Absolutely! Here’s a step-by-step explanation of what this Cypher query does, in beginner-friendly terms:
MATCH (start:Section {clauseNumber: '10.6.4'})
Section
where the property clauseNumber
is '10.6.4'
.start
for the rest of the query.OPTIONAL MATCH (start)-[:PARENT_OF]->(parent:Section)
OPTIONAL MATCH (start)-[:CHILD_OF]->(child:Section)
OPTIONAL MATCH path=(start)-[:LINKS_TO*]->(linked:Section)
OPTIONAL MATCH
means: “Try to find this pattern, but if it doesn’t exist, don’t fail the query.”Section
node that is a parent of start
.Section
node that is a child of start
.Section
node that is linked to start
by one or more LINKS_TO
relationships, even if there are several hops (the *
means “follow as many as you can”).WITH COLLECT(DISTINCT parent) AS parents, COLLECT(DISTINCT child) AS children, COLLECT(DISTINCT linked) AS linkedNodes, start
DISTINCT
).start
node.UNWIND parents + children + linkedNodes + [start] AS node
UNWIND
turns this list into individual rows, each with a node
.WITH DISTINCT node
WHERE node IS NOT NULL
WITH DISTINCT node
ensures each node only appears once.WHERE node IS NOT NULL
removes any empty results (in case there were no parents, children, or links).RETURN node.id AS id, node.clause AS clause, node.clauseNumber AS clauseNumber, node.requirement AS requirement
id
, clause
, clauseNumber
, and requirement
properties.This query finds a specific section (10.6.4), then gathers:
It then returns some key information about each of these nodes, with no duplicates.
If you want more details about any part, just ask!
MATCH (start:Section {clauseNumber: '10.6.4'})
OPTIONAL MATCH (start)-[:PARENT_OF]->(parent:Section)
OPTIONAL MATCH (start)-[:CHILD_OF]->(child:Section)
OPTIONAL MATCH path=(start)-[:LINKS_TO*]->(linked:Section)
WITH COLLECT(DISTINCT parent) AS parents, COLLECT(DISTINCT child) AS children, COLLECT(DISTINCT linked) AS linkedNodes, start
UNWIND parents + children + linkedNodes + [start] AS node
WITH DISTINCT node
WHERE node IS NOT NULL
RETURN node.id AS id, node.clause AS clause, node.clauseNumber AS clauseNumber, node.requirement AS requirement