Reputation: 846
I tried to delete a relationship, and this little-documented error shows up.
The query:
MATCH ()-[r:SendTo]-(n:Wallet)
WHERE NOT ()-[:BelongTo]->(n)
DELETE r
RETURN r
The whole error output:
Exception in thread "main" org.neo4j.driver.v1.exceptions.value.NotMultiValued: NULL is not a keyed collection
at org.neo4j.driver.internal.value.ValueAdapter.get(ValueAdapter.java:192)
at basicANeo4j.Importer.<init>(Importer.java:213)
at basicANeo4j.Importer.main(Importer.java:246)
When I checked the corresponding relationship, there is no property of it which is null:
<id>:595 value_bitcoin:20000000000outputIndex:defaultuniqueReferenceTran:bcaeee45968b5a08c88ed7a0d90a1275728eda356013465408197e9f77c634daNULLtranHashString:bcaeee45968b5a08c88ed7a0d90a1275728eda356013465408197e9f77c634datime:2016-01-01T22:55:26type:pubkeyhashvalue_dollar:86554.0estChanAddr:3KgtbGgaX2ngstNpvyv7LwpHSweVeqGbpM
I looked into ValueAdapter.class, this is the relevant code:
@Override
public Value get( String key )
{
throw new NotMultiValued( type().name() + " is not a keyed collection" );
}
Without any documentation, it does not help at all.
Upvotes: 0
Views: 951
Reputation: 846
I just realized where the error of keyed collection come from: while iterating through the records, I tried to print a property of the relationship, while the property does not exist for this relatioship. (I copied it from another part of my code without checking it and was convinced that it is the query which is the problem. So I missed that.)
Upvotes: 0
Reputation: 30397
As Tomaz says, this is because you can't return a node or relationship you just deleted.
However, you can get a map "snapshot" of a node or relationship, delete the node or relationship, then return the snapshot.
Here's the article in the knowledge base.
Upvotes: 3
Reputation: 6524
I think this is because you are trying to return a null object because you deleted it first. I would try this
MATCH ()-[r:SendTo]-(n:Wallet)
WHERE NOT ()-[:BelongTo]->(n)
DELETE r
RETURN 'success'
You can return either a string, could return n if you are interested in which wallet had relationships deleted or you could not return anything.
Upvotes: 1