Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a way to get length of a string in Neo4j cypher?

Tags:

neo4j

cypher

pretty simple question, is there a way to get length of a string in Neo4j cypher? I cannot find any document for that.

thanks

like image 866
Qun Wang Avatar asked Dec 02 '13 08:12

Qun Wang


People also ask

How do you count in Neo4j?

In Neo4j database, COUNT() function is used to count the number of rows. Syntax: MATCH (n { name: 'A' })-->(x) RETURN n, count(*)

What is coalesce in Neo4j?

The function coalesce() returns the first non- null value in the given list of expressions. Syntax: coalesce(expression [, expression]*) Returns: The type of the value returned will be that of the first non- null expression.

WHAT IS WITH clause in Cypher?

The WITH clause allows query parts to be chained together, piping the results from one to be used as starting points or criteria in the next. It is important to note that WITH affects variables in scope.


1 Answers

To return the length of a string in Cypher, use the SIZE() function. The LENGTH() function is now exclusively used for measuring PATHs in the graph.

RETURN size("This is an example string")

yields 25

From the good folks at Neo: "This feature is deprecated and will be removed in future versions. Using length on anything that is not a path is deprecated, please use size instead"

like image 170
Adam Rentschler Avatar answered Nov 14 '22 18:11

Adam Rentschler