Determining Node Label 'Names'
Determining Node labels
From a post on the Neo4j blog we have a path to finding our generic node name (x)
How do I display all nodes with no defined labels
Although assigning a node one or more labels provides many benefits (i.e. performance gains from index usage, ability to group nodes into sets, etc), it is possible to create a node without any labels.
The following Cypher can be used to identify all nodes in the graph which have no label defined:
MATCH (n) WHERE SIZE(labels(n)) = 0 RETURN n
It points the way for us to do some generic style Cypher (and solve for (x) ).
What is node label (x)?
Assuming we have a network of nodes (c) and we are tasked with applying common metadata against these nodes with fixed values and groupings it makes sense to utilise the strengths of the graph engine to 'TAG' the nodes in the network represented by (c).
If we create several 'tag' nodes and our sample node (c); for example:
CREATE (x:UPWARD {name:'upward'})
CREATE (x:DOWNWARD {name:'downward'})
CREATE (x:EAST {name:'east'})
CREATE (x:WEST{name:'west'})
CREATE (c:SAMPLE {name:'sample1'})
MATCH (c:SAMPLE {name:'sample1'}) , (x:UPWARD {name:'upward'})
MERGE (c)-[:HASTAG]->(x)
MATCH (c:SAMPLE {name:'sample1'}) , (x:EAST {name:'east'})
MERGE (c)-[:HASTAG]->(x)
"sample1" "UPWARD"
"sample1" "EAST"
With some careful thought this can be a powerful addition to your toolbox.
Comments
Post a Comment