I have a graph with cycles, and I want query the data in difference scenario according to a schema tree.
The data like this:
Custom->Order->Product
->Service
->Country
https://i.stack.imgur.com/ePF1s.png
and business want custom nation info and services, according to a schema tree.
Custom->Order->Service
->Country
I can write a static query like this
match(c:Custom)-[r1:is]->(m:Country)
match(c)-[o:order]->(o1:Order)-[r2:has]->(s:Service)
return c,r1,m,o,o1,r2,s
https://i.stack.imgur.com/THqA1.png
BUT the schema tree will be more complex, how can I make a query dynamic with the schema tree?
The question also on StackOverflow:
https://stackoverflow.com/questions/72682032/how-to-query-a-tree-in-graph-dynamically-with-a-schema-tree
Test data:
create (r:root{name:'root'})
CREATE (c1:Custom{name:'alex'})
CREATE (c2:Custom{name:'jerry'})
CREATE (o1:Order{no:'a-1'})
CREATE (o2:Order{no:'a-2'})
CREATE (p1:Product{name:'apple'})
CREATE (p2:Product{name:'banana'})
CREATE (s1:Service{name:'service1'})
CREATE (s2:Service{name:'service2'})
CREATE (m1:Country{name:'us'})
CREATE (m2:Country{name:'au'})
create (r)-[a:root]->(c1)
create (r)-[b:root]->(c2)
create (c1)-[r1:order]->(o1)-[rr1:category]->(p1)
create (c2)-[r2:order]->(o2)-[rr2:category]->(p2)
create (o1)-[r3:has]->(s1)
create (o2)-[r4:has]->(s2)
create (c1)-[r5:is]->(m1)
create (c2)-[r6:is]->(m2)
Stackoverflow: https://stackoverflow.com/questions/72682032/how-to-query-a-tree-in-graph-dynamically-with-a-schema-tree