Hi there,

Aggregation today only aggregates data over multiple subgraphs. Your query
produces one subgraph per path, and that is why you can't do what you want
to do.

This is definitely something I want Cypher to support.

<technical details>
The way I see this working is two steps:

   1. Cypher needs a way to turn an iterable of nodes to an iterable of of
   numeric values. Something like Scala collection's map method. It could look
   something like this: RETURN MAP(x in NODES(p) : x.votes)
   2. Aggregate functions need to be able to work on iterables, and not just
   on multiple subgraphs. The problem here is how to make it obvious which one
   you are trying to use, e.g.
   RETURN foo.bar, COUNT(NODES(path))
   Does that mean aggregate on foo.bar and return the number of paths, or
   does it mean that you want to know the number of nodes in path?

If/when this is done, your query would look something like this:

RETURN SUM(MAP(x in NODES(path) : x.votes))

Any feedback on this is most welcome!
</technical details>

tl;dr;
Cypher can't do it today. It's a use case that's very interesting for us to
solve.


On Tue, Oct 25, 2011 at 12:02 PM, n_aschbacher <[email protected]>wrote:

> Hi,
>
> You're correct in one sense.  If I remove the path, or other columns, from
> the RETURN statement then I can get a single SUM value back for all the
> properties in the entire tree below my starting node.
>
> My problem is that I want to return multiple rows, a row for each path
> through the graph, with the SUM of the properties of the nodes traversed so
> far on that single path.
>
> The idea is that I want to know which branch in the tree of posts and
> replies has the highest total vote count.
>
> Removing other columns from the RETURN statement as you suggest will only
> give me the SUM of votes for the whole tree, not per branch.
>
> Cheers!
>
> --
> View this message in context:
> http://neo4j-community-discussions.438527.n3.nabble.com/Cypher-Aggregation-functions-specifically-SUM-tp3450203p3450996.html
> Sent from the Neo4j Community Discussions mailing list archive at
> Nabble.com.
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to