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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -