cancel
Showing results for 
Search instead for 
Did you mean: 

How can I store the result of COLLECT(x) as a property in a relationship?

and_manousakis
Node Clone

I'm working on a bitcoin graph where a part of a path is the following:

(address)-[i:input]->(transaction)

Most of the times there are thousands of input relationships between an address and a transaction. I'm trying to aggregate the relationships, create a new one, store the result of the aggregation and delete the old relationships. However, I get the following error:

Neo4j only supports a subset of Cypher types for storage as singleton or array properties. Please refer to section cypher/syntax/values of the manual for more details.

This is the query I ran:

MATCH (a:address {addressID: "some_hash"})-[i:input]->(tx:transaction {hash:"some_hash"})
WITH a AS address, tx AS transaction, COLLECT(i) AS input_attr
MERGE (address)-[inc:incoming]->(transaction)
SET inc.input_attributes = input_attr
RETURN address, transaction, inc

How could I do that? The part of deleting the old relationships is missing.

Thanks
Andreas

1 ACCEPTED SOLUTION

glilienfield
Ninja
Ninja

The variable 'i' is bound to a relationship entity. As I understand it, Neo4j can only assign primitive types or arrays of same as a property.

View solution in original post

2 REPLIES 2

glilienfield
Ninja
Ninja

The variable 'i' is bound to a relationship entity. As I understand it, Neo4j can only assign primitive types or arrays of same as a property.

and_manousakis
Node Clone

@glilienfield thanks for the answer!

It was implemented as you advised with the array. The values of a single feature where collected from multiple edges and stored in an array. Then that array was stored in a new edge. 😃