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.

Neo4j Cypher Projection Query via py2neo

I am trying to write a cypher query via py2neo.

#UserList to be passed as array   
params = {}
   params['UserList'] = ['Mason']

    # Cypher Projection
    queCreateGraph = """
                    CALL gds.graph.create.cypher(
                    'Test1',
                    'MATCH (n) WHERE n.name in $UserList OR n:FunctionNode RETURN id(n) AS id, labels(n) AS labels',
                    'MATCH (n)-[r:LikedBy]->(m) WHERE m.name in $UserList RETURN id(n) AS source, id(m) AS target, type(r) AS type')
                    YIELD
                    graphName AS graph, nodeQuery, nodeCount AS nodes, relationshipCount AS rels
                     """
    graph.query(queCreateGraph, params)

I am basically trying to use UserList as a list to pass into the cypher projection but I am getting this error - py2neo.errors.ClientError: [Procedure.ProcedureCallFailed] Failed to invoke procedure gds.graph.create.cypher: Caused by: org.neo4j.exceptions.ParameterNotFoundException: Expected parameter(s): UserList

1 REPLY 1

Not sure why it is not working, but maybe try these two things to see if you can get it working. 

1. Initialize the map directly

params = {'UserList': ['Mason']}

2. Add parameter using 'with' clause:

    queCreateGraph = """
                    WITH ['Mason'] as UserList
                    CALL gds.graph.create.cypher(
                    'Test1',
                    'MATCH (n) WHERE n.name in UserList OR n:FunctionNode RETURN id(n) AS id, labels(n) AS labels',
                    'MATCH (n)-[r:LikedBy]->(m) WHERE m.name in UserList RETURN id(n) AS source, id(m) AS target, type(r) AS type')
                    YIELD
                    graphName AS graph, nodeQuery, nodeCount AS nodes, relationshipCount AS rels
                     """