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.

Neo.ClientError.Statement.SyntaxError

CALL gds.degree.stream('mysna')
YIELD nodeId, score
where row.source= 'aniesbaswedan'
RETURN gds.util.asNode(nodeId).name AS name, score AS followers
ORDER BY followers DESC, name DESC limit 100

Neo.ClientError.Statement.SyntaxError

Variable `row` not defined (line 3, column 7 (offset: 58))
"where row.source= 'aniesbaswedan'"
       ^
I want to do a filter in gds, is this possible?
5 REPLIES 5

You could filter the nodes post-processing to return only the ones you want. Assuming the ‘source’ is a property of the nodes you projected, you can filters those from your result with the following query:

CALL gds.degree.stream('mysna')
YIELD nodeId, score
WITH gds.util.asNode(nodeId) node, score AS followers
WHERE node.source = ‘aniesbaswedan’
RETURN node.name as name, followers
ORDER BY followers DESC, name DESC limit 100
 
is this what you are looking for? 

 
You can also investigate using cypher projection to project only the nodes you want. 

IF filter nodes before processing, how? I tried this way, error

CALL gds.betweenness.stream('mysna', {row.source = 'aniesbaswedan'})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC limit 100
 

Neo.ClientError.Statement.SyntaxError

Invalid input '{': expected "+" or "-" (line 1, column 38 (offset: 37))
"CALL gds.betweenness.stream('mysna', {row.source = 'aniesbaswedan'})"

I think you can achieve it by using cypher projection. You can specify what nodes you want projected through a cypher query, allowing you to filter what gets projected.

https://neo4j.com/docs/graph-data-science/current/graph-project-cypher/

 

thank you, 

this can ran

CALL gds.degree.stream('mysna')
YIELD nodeId, score
WHERE gds.util.asNode(nodeId).name = 'aniesbaswedan'
RETURN gds.util.asNode(nodeId).name AS name, score AS followers
ORDER BY followers DESC, name DESC limit 100

 

Sorry, there was a slight syntax error in my earlier post.  It was missing an 'as' clause to bind the 'node' variable.

CALL gds.degree.stream('mysna') YIELD nodeId, score
WITH gds.util.asNode(nodeId) as node, score AS followers
WHERE node.source = 'aniesbaswedan'
RETURN node.name as name, followers
ORDER BY followers DESC, name DESC limit 100
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online