Unknown target node error

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

	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',

I'm receiving the following error

Failed to invoke procedure '' : 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!

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

1 Like

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! :+1:

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

See the syntax section here -

1 Like