cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Getting an error while executing the code

I am new to neo4j and knowledgegraph. need help with the below issue.

def who_be_present(I_AM,I_WANT_TO_MEET):
print(f"I'm {I_AM}")
print(f"I want to meet {I_WANT_TO_MEET}")
request="""
MATCH (cs:Person { name:$pfrom }),(ms:Person { name:$pto }), p = shortestPath((cs)-[:ACTED_IN|:DIRECTED*]-(ms))
WHERE length(p)> 1
RETURN p
"""
cursor = graph.run(request,pfrom=I_AM,pto=I_WANT_TO_MEET)
while cursor.forward():
print(cursor['p'])
print('\n')


I_AM='Brad Anderson'
I_WANT_TO_MEET='Brad Pitt'
who_be_present(I_AM,I_WANT_TO_MEET)

I_AM='Kanwaljeet Singh'
I_WANT_TO_MEET='Nick Nolte'
who_be_present(I_AM,I_WANT_TO_MEET)

---------------------------------

The error says 

ClientError: [Statement.SyntaxError] The semantics of using colon in the separation of alternative relationship types in conjunction with
the use of variable binding, inlined property predicates, or variable length is no longer supported.
Please separate the relationships types using `:A|B|C` instead (line 2, column 83 (offset: 87))
"    MATCH (cs:Person { name:$pfrom }),(ms:Person { name:$pto }), p = shortestPath((cs)-[:ACTED_IN|:DIRECTED*]-(ms))"


 

1 REPLY 1

Hello @PhilipGeorge 🙂

You must remove the ":" in the path MATCH clause:

MATCH (cs:Person {name:$pfrom}) 
MATCH (ms:Person {name:$pto}) 
MATCH path = shortestPath((cs)-[:ACTED_IN|DIRECTED*]-(ms)) 
WHERE length(path)> 1 
RETURN path

Regards,
Cobra