· neo4j cypher

neo4j/cypher: CREATE UNIQUE - "SyntaxException: string matching regex ``$' expected but ``p' found"

I’ve been playing around with the mutating cypher syntax of neo4j which allows you to make changes to the graph as well as query it, a feature introduced into cypher in May in release 1.8 M01.

I was trying to make use of the 'CREATE UNIQUE' syntax which allows you to create nodes/relationships if they’re missing but won’t do anything if they already exists.

I had something like the following:

START product1=node:products('product_id:1')
CREATE UNIQUE product1-[:sold]->(sales200010 {type:"product_sales", value: 1, name: "Oct 2000 Sales"})

So I already have a product indexed with a 'product_id' of 1 and I wanted to create a relationship to a node defining the sales for that product.

When I tried to execute that query I was ending up with the following error:

SyntaxException: string matching regex `$' expected but `p' found

Think we should have better error message here? Help us by sending this query to cypher@neo4j.org.

Thank you, the Neo4j Team.

I was a bit puzzled as to why that wouldn’t work but eventually I read the release notes for 1.8 M07 where I learnt that in earlier versions of neo4j 'CREATE UNIQUE' had actually been known as 'RELATE' instead.

Since I’m using 1.8 M06 at the moment I just needed to change 'CREATE UNIQUE' to 'RELATE' but RC1 is now available so I’ll soon switch to that and go back to 'CREATE UNIQUE' again.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket