You're almost there.

Match (a:Action)
with a.type as type, a  order by a.date
return  type, collect(a)[0..20] as actions

On Tue, Jun 14, 2016 at 10:00 PM, S Ben <suri...@gmail.com> wrote:

> So here's the deal, I'm using Neo4J 3.01 and I have a graph with nodes of
> type Action which have amongst other links and properties the following two:
> Type: [Comment,Reply,Vote etc]
> Date:[epoch timestamp]
> I am attempting to run a cypher query that returns a sorted list of nodes
> ordered by the date field but collapsing (Collect?) sequential items of the
> same type
> So for the following nodes:
>
> {*type*:'Comment',*date*:1}
> {*type*:'Comment',*date*:2}
> {*type*:'Vote',*date*:3}
> {*type*:'Comment',*date*:4}
> {*type*:'Comment',*date*:5}
> {*type*:'Reply',*date*:6}
> {*type*:'Reply',*date*:7}
> {*type*:'Vote',*date*:8}
> {*type*:'Vote',*date*:9}
>
>
> I would hope to get something like:
>
> {*type*:'Comment',*actions*:[{*type*:'Comment',*date*:1},{*type*
> :'Comment',*date*:2}]}
> {*type*:'Vote',*actions*:[{*type*:'Vote',*date*:3}]}
> {*type*:'Comment',*actions*:[{*type*:'Comment',*date*:4},{*type*
> :'Comment',*date*:5}]}
> {*type*:'Reply',*actions*:[{*type*:'Reply',*date*:6},{*type*:'Reply',
> *date*:7}]}
> {*type*:'Vote',*actions*:[{*type*:'Vote',*date*:8},{*type*:'Vote',*date*
> :9}]}
>
>
> I attempted a simple collect and order cypher query:
>
>> Match (a:Action)
>> with a.type as type, a  order by a.date limit 20
>> return  type, collect(a) as actions
>
>
>  but this seems to collect each type in its own group regardless of the
> sequence, so the actual result is something like:
>
> {*type*:'Comment',*actions*:[{*type*:'Comment',*date*:1},{*type*
> :'Comment',*date*:2},{*type*:'Comment',*date*:4},{*type*:'Comment',*date*
> :5}]}
> {*type*:'Vote',*actions*:[{*type*:'Vote',*date*:3},{*type*:'Vote',*date*
> :8},{*type*:'Vote',*date*:9}]}
> {*type*:'Reply',*actions*:[{*type*:'Reply',*date*:6},{*type*:'Reply',
> *date*:7}]}
>
>
> Any Ideas of how to acheive this using cypher? I have tried different
> means of collect and sorts but to no avail
>
> Any help would be great
>
> --
> 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 neo4j+unsubscr...@googlegroups.com.
> For more options, visit 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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to