Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use numbers for relationship types in Neo4j?

I've created some nodes, and relationships between them with numerical types (eg '3'). Creation works fine, but now I'm having trouble selecting them with Cypher.

Since it allows me to create them, I'm assuming the error I'm getting is either something I'm doing wrong, or a bug?

Here's an example. The first query works, and returns a relationship with type '3'. However, when I change it to specify only relationships of type 3, I get an error.

neo4j-sh (?)$ START n=node(127) MATCH n-[r]-m RETURN n, r, m;
==> +--------------------------------------------------------------------------------+
==> | n                                 | r           | m                            |
==> +--------------------------------------------------------------------------------+
==> | Node[127]{user_id:"1",name:"Bob"} | :3[0] {}    | Node[118]{category:"state"}  |

neo4j-sh (?)$ START n=node(127) MATCH n-[r:3]-m RETURN n, r, m;
==> SyntaxException: string matching regex ``(``|[^`])*`' expected but `3' found
==> 
==> Think we should have better error message here? Help us by sending this query to [email protected].
==> 
==> Thank you, the Neo4j Team.
==> 
==> "START n=node(127) MATCH n-[r:3]-m RETURN n, r, m"
like image 235
DougW Avatar asked Oct 31 '25 06:10

DougW


1 Answers

Clearly I just needed some sleep. Banged my head on this for a while yesterday, but just figured out the answer. Apparently numbers fall into the "uncommon characters" category, and need to be surrounded with backticks.

http://docs.neo4j.org/chunked/stable/query-match.html#match-relationship-types-with-uncommon-characters

Now it works just fine.

like image 123
DougW Avatar answered Nov 02 '25 21:11

DougW



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!