It works, it's a bit cumbersome but also useful to speed up your query (reduce 
cardinality again)
(And don't forget the direction).

> OPTIONAL MATCH (post:Post)-[:post_author]->author
WITH post, collect(author) as authors
>        OPTIONAL MATCH post-[:posted_photos]->photo
WITH post, authors, collect(photo) as photos
...

you can also do it with extracting information from a path expression, but 
that's currently not so nice (hopefully easier at some point with path 
comprehensions)

MATCH (post:Post {id:23948})
RETURN post, 
                [path in (post)-[:post_author]->() | last(nodes(path))] as 
authors, 
                [path in (post)-[:posted_photos]->() | last(nodes(path))] as 
photos, ...

You could even combine it:

MATCH (post:Post {id:23948})
RETURN post, 
                [path in (post)-[:post_author|:posted_photos]->() | 
[type(head(rels(path))), last(nodes(path))]] as details, ...


For the photos you can also use the transitive path (2 steps) to collect the 
information

Michael

> Am 15.03.2015 um 09:17 schrieb Daniel Modry <[email protected]>:
> 
> Ohh that's perfect AGGREGATION, good to know it. Thank you many times.
> 
> 
> But I still can't find a way to limit unaggregated output:
> 
>  OPTIONAL MATCH (post:Post)-[:post_author]-author
>        OPTIONAL MATCH post-[:posted_photos]-photo
>        OPTIONAL MATCH photo-[:sizes]-size
>        OPTIONAL MATCH photo-[:comments]-comment
>        OPTIONAL MATCH photo-[:album_photos]-album
> 
> Do I have to use many queries, or is it possible with some trick to get let 
> say 10 last posts, 5 photos and 3 comments?
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to