Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use parameter in neo4j cypher query

Tags:

neo4j

cypher

The Cypher official documentation seems to be inconsistent and misleading when it comes to assigning parameter values..we have the following examples in the refcard:

SET n.property1 = $value1

where value1 is a parameter defined

{
 "value1": somevalue
}

However if you use this SET syntax you get an error value1 not defined. The correct syntax seems to be:

SET n.property1 = {value1}

also if its a MATCH query the parameter looks like this:

  {
     email: someemail
    }

note no quotes around email So if you have a MATCH and SET query with parameters you parameters definition looks like this:

{
email: someemail,
"status" : somestatus
}

Can someone explain this apparent inconsistency?

EDIT: This is also an example from the neo4j docs:

using parameter with SET clause:

{
  "surname" : "Taylor"
}

MATCH (n { name: 'Andres' })
SET n.surname = $surname
RETURN n

This returns surname undefined.

like image 859
MichaelE Avatar asked Oct 24 '25 21:10

MichaelE


1 Answers

You can set params in neo4j desktop browser using :params.

For eg,

  1. Execute, :params {surname: 'Taylor'}
  2. Execute, MATCH (n { name: 'Andres' }) SET n.surname = $surname RETURN n

For more info of params, use :help params

like image 150
Vaibhav Srivastava Avatar answered Oct 28 '25 05:10

Vaibhav Srivastava



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!