neo4j - Aggregate over a list of matching nodes -
i have cypher query i'd expand summed on list of matching nodes.
my query looks this:
match (u:user {name: {input} })-[r:uses]-(t) return sum(t.weight)
this matches 1 user node, , i'd adjust match list of user nodes , perform aggregation.
my current implementation calls query in loop , performs aggregation outside of cypher. results in inaccurate results , lot of api calls.
is there way evaluate cypher query against list of elements (strings in case)?
i'm using neo4j 2.1 or 2.2.
cheers
you can use in
operator , pass in array of usernames:
match (u:user)-[r:uses]-(t) u.name in ['john','jim','jack'] return u.name, sum(t.weight)
instead of array here can use parameter holding , array value well:
match (u:user)-[r:uses]-(t) u.name in {usernames} return u.name, sum(t.weight) usernames = ['john','jim','jack']
Comments
Post a Comment