简体   繁体   中英

Neo4j Cypher Projection Query

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

This Code Works:

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',
                    {parameters: {UserList: $UserList } } )
                    YIELD
                    graphName AS graph, nodeQuery, nodeCount AS nodes, relationshipCount AS rels

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM