Question

I am trying to make the following Cypher query:

start me = node:actors(actor = 'Tom Baker') , you = node:actors(actor = 'Peter Davison') match p = you-[*1..3]-me return p

using the Dr.Who dataset available in the neo4j site. It gives correct results in the Neo4j console as well as correct result in Py2Neo. However now I want to make the query in such a way such that

x='Tom Baker'
y='Peter Davison'

and make the same query using the variables x and y. However I dont know the escape sequence for Py2Neo. I tried the below query

"start me = node:actors(actor = \'.x.\') , you = node:actors(actor = \'.y.\') match p = you-[*1..3]-me return p"

but it didnt work. Any help would be appreciated.

Was it helpful?

Solution

Try to use parameters instead, named parameters in cypher are {name} and you pass a hash/dictionary with the name-value pairs along with the query.

start me = node:actors(actor = {me}) , 
you = node:actors(actor = {you}) 
match p = you-[*1..3]-me 
return p

params: {"me":"Tom Baker","you":"Peter Davison"}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top