How to order data when collecting (collect)?

44 views
Skip to first unread message

Тарасов Константин

unread,
Oct 1, 2012, 5:12:26 AM10/1/12
to ne...@googlegroups.com
My cypher query is
START root=node(1)
MATCH root
-[r*..3]->tag
return collect(tag) as tags, collect(r) as rels

adding ORDER BY at the end cause syntax error:
ORDER BY tag.name

what is solution to order data when collecting?

terrasoff

unread,
Oct 2, 2012, 5:33:40 AM10/2/12
to ne...@googlegroups.com
Note, query above is faster than
START root=node(1)
MATCH root
-[r*..3]->tag
return tag,r
sure, in this case ORDER isn't problem 

Peter Neubauer

unread,
Oct 2, 2012, 4:07:17 PM10/2/12
to ne...@googlegroups.com
Mmh,
good question. I think COLLECT does not make any guarantees about
ordering, it is an unordered collection. What is your us case? Why not
in that case return TAG, and order by TAG.name?

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Wanna learn something new? Come to http://graphconnect.com
> --
>
>

Wes Freeman

unread,
Oct 10, 2012, 12:03:01 AM10/10/12
to ne...@googlegroups.com
My latest pull request should enable this use case:

Syntax would be:
START root=node(1)
MATCH root
-[r*..3]->tag
WITH tag, r
ORDER by tag.name
RETURN collect(tag) as tags, collect(r) as rels

Wes

--



Reply all
Reply to author
Forward
0 new messages