Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-21-2022 02:33 AM - edited 06-21-2022 02:36 AM
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-...
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-...
06-21-2022 02:45 AM
Hi @ourdark ,
Based on what I read on your StackOverflow reply, I think you may like taking a look into https://neo4j.com/labs/apoc/4.1/graph-querying/expand-paths-config/ as already suggested. In particular, you may like checking the behavior of *relationshipFilter* and *labelFilter*.
All the sessions of the conference are now available online