Posts

Showing posts from August, 2020

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:DO...

Property DataType - apoc.meta.type

Node Properties in Neo4j. A property can be of any datatype even within nodes of the same label. Nodes have no fixed schema as with the RDBMS where most notions of data storage are formed and 'best practice' is enforced.  Properties themselves do not have types, but the values they hold do. However, you can have a property, X which could be assigned a string value or a numeric value. There is no enforcement of typing for a property. Of course, it would not (always) make sense to assign a property different type values in your graph. So, just what datatype is the property? Trusty APOC has a function for that. WITH [true, 42, 'foo', 1.2] AS data UNWIND data as value RETURN apoc.meta.type(value) So, just what datatype is the property? "BOOLEAN" "INTEGER" "STRING" "FLOAT" You can use this function in MATCHES on nodes in your system where properties are unknown at runtime. MATCH (n:MyNode) RETURN apoc.meta.type(n.MyProperty)