Awais Tariq
Awais Tariq

Reputation: 33

How to find nodes with string type property in Neo4j?

I have a label Users which has a property userid. So I want to fetch all nodes which have string type userid. Is it possible?

Like:

MATCH (n:Users) where n.userid IS string RETURN n

Upvotes: 2

Views: 3984

Answers (1)

Bruno Peres
Bruno Peres

Reputation: 16355

There is no out-of-the-box feature to check data types in Neo4j, but you can implicitly check if a given value is a string trying to convert to string and comparing to the original value, like this:

match (n:Users)
where toString(n.userid) = n.userid
RETURN n

Also, you can install APOC Library and use the function apoc.meta.type, this way:

match (n:Users)
where apoc.meta.type(n.userid) = "STRING"
return n

Upvotes: 7

Related Questions