0

How can you find the length of a property variable of a node or edge? Something like LENGTH() function doesn't exist in Cypher.

Does Memgraph have a built-in function or a way to return the length of a property variable?

Taja Jan
  • 942
  • 1
  • 1
  • 11
  • There is a `length` function in Cypher, it can be used to compute the length of a path. There is also a `size` function. I realize this is a self answered post but perhaps consider clarifying the question, as, as written, it is a bit confusing. – Kelvin Lawrence Aug 16 '23 at 14:00
  • @kelvin thanks for the pointer. I've taken a look at the list of implantation differences between Cypher variants (https://memgraph.com/docs/cypher-manual/differences#unsupported-functions) and there it is says "length() is named size() in Memgraph." – Taja Jan Aug 21 '23 at 10:50

1 Answers1

0

In the Graph Style Script (GSS) built-in functions, there is a Size function that can return the size of a property variable. If the value is of type Node, it returns the size of node properties. If the value is of type Relationship, it returns the size of relationship properties. For example, Size(Property(node, "name")) returns the size of the node's name property. You can find more details about this function in the official documenataion.

In the Python API, there is a len function that can be used to get the number of properties on a vertex or edge. For example, len(vertex.properties) or len(edge.properties). You can find more details about this function in the reference guide.

Taja Jan
  • 942
  • 1
  • 1
  • 11