[
https://issues.apache.org/jira/browse/TINKERPOP-1212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15198355#comment-15198355
]
Marko A. Rodriguez commented on TINKERPOP-1212:
-----------------------------------------------
You can read it like this (sorta):
{code}
g.V().hasLabel("movie").as("id","name","avgRating").
union(
select("id").by("id"),
select("name").by("name"),
select("avgRating").by(inE("rated").values("rating").mean())).
order().by(select("avgRating"), decr).limit(10)
{code}
> Better support for aggregation
> ------------------------------
>
> Key: TINKERPOP-1212
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1212
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.1.1-incubating
> Reporter: Matthias Broecheler
>
> Currently, it is pretty verbose to write aggregate queries in Gremlin. For
> instance, consider a simple query that asks for the top 10 movies by average
> rating:
> {code}
> g.V().hasLabel("movie").order().by("avgRating",inE("rated").values("rating").mean(),
> decr).limit(10).values("id","name","avgRating")
> {code}
> The problem here is that you have to repeat that nested traversal in order to
> get the actual rating. What's even worse is the fact that this will be
> computed twice. In aggregates, it is very common to order and then retrieve
> by some aggregate. As such, we should be treating those as "virtual
> properties" on the elements that are being aggregated and be able to refer to
> them as properties:
> {code}
> g.V().hasLabel("movie").order().by(inE("rated").values("rating").mean(),
> decr).limit(10).group().by(inE("rated").values('rating').mean())
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)