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.

Gds.alpha.degree.write Unknown target node error

Minyall
Node Link

I'm trying to run this query, which is based on the sample code given on the docs for degree centrality

CALL gds.alpha.degree.write({
	nodeQuery: 'MATCH (n:USER)-[:COLLECTED_AT_STEP]->(:STEP {step_val:1}) RETURN id(n) as id',
	relationshipQuery:'MATCH (u1:USER)-[:FOLLOWS]->(u2:USER) RETURN id(u1) AS source, id(u2) AS target',
    writeProperty:'in_degree'
        })

I'm receiving the following error

Failed to invoke procedure 'gds.alpha.degree.write' : Caused by: java.lang.IllegalStateException: Failed to load relationship with unknown target-node id 1.

I've run both the nodeQuery and the relationshipQuery independently and both resolve fine, so I'm at a bit of a loss as to what is the issue. Many thanks for any advice!

1 ACCEPTED SOLUTION

I believe the error is indicating that the relationshipQuery returned a node that is not present in the nodeQuery results, right?

You'll notice that in the example they are sending in literally every node for nodeQuery

MATCH (u:User) RETURN id(u) AS id

I don't imagine you have to do that, but it does appear that all the nodes referenced in the relationship query must need to be present in nodeQuery, if I read the error text correctly.

Failed to load relationship with unknown target-node id 1

View solution in original post

3 REPLIES 3

I believe the error is indicating that the relationshipQuery returned a node that is not present in the nodeQuery results, right?

You'll notice that in the example they are sending in literally every node for nodeQuery

MATCH (u:User) RETURN id(u) AS id

I don't imagine you have to do that, but it does appear that all the nodes referenced in the relationship query must need to be present in nodeQuery, if I read the error text correctly.

Failed to load relationship with unknown target-node id 1

Minyall
Node Link

Ah! OK I get it. I was thinking of the node query as a filter, i.e. First select the nodes that the relationship query will then use, whereas actually I should be doing that filtering stage in the relationship query itself.

Thanks this was very helpful!

You can set validateRelationships:false to have it ignore missing relationships.

See the syntax section here - https://neo4j.com/docs/graph-data-science/current/management-ops/cypher-projection/#cypher-projectio...