MichaelE
MichaelE

Reputation: 767

How to use parameter in neo4j cypher query

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.

Upvotes: 4

Views: 3672

Answers (1)

Vaibhav Srivastava
Vaibhav Srivastava

Reputation: 41

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

Upvotes: 4

Related Questions