Reputation: 43
I am using Neo4J neosemantics plugin to load ontology. I want to find the path (all intermediate nodes and edges with their properties) from root of the tree to a particular node. What would be the best (optimal) way to get this information in cypher? The nodes are connected through subclassof relationships.
Upvotes: 0
Views: 360
Reputation: 21
If you import an ontology with neosemantics using the basic settings, you can get the path(s) between a class and it's parents all the way to the root with the following query. (I've imported the ESCO ontology):
MATCH path = (c:n4sch__Class)-[:n4sch__SCO*]->(root:n4sch__Class) //(1)
WHERE c.uri = "http://data.europa.eu/esco/skill/74ce6ebc-8886-437e-bee9-ce5735aaa020" // (2)
AND not (root)-[:n4sch__SCO]->() //(3)
RETURN path //(4)
RETURN [n in nodes(path) | n.skos__prefLabel]
Upvotes: 1