Hi Raúl,

You can order using a WITH before you collect them in the RETURN clause,
like this:

MATCH (h:Country)<-[r:BELONGS_TO]-(u:User),
      (u)-[:RECEIVED]->(nx:Notification)
WITH u, h, nx ORDER BY nx.text
RETURN u.id AS userid,
       h.code AS homecountry,
       collect(nx.text) AS notifications

HTH,

Andrés

On Tue, Mar 4, 2014 at 3:42 PM, Raúl Kripalani <[email protected]>wrote:

> Hello,
>
> My graph is quite simple and the relevant parts look like this:
>
> u:User ---[BELONGS_TO]-----------> (*..1) h:Country, properties: code
>     |
>     |-----[RECEIVED]-------------> (1..*) nx:Notification, properties:text
> , ordinal
>
>
> All nx:Notification nodes have a property 'ordinal' which is a global
> counter for all notification nodes in the graph, from 0 to infinity.
>
> I'm running a query to retrieve all users with their countries and to
> collect() their nx.text properties. However, I need that the elements in
> these collections be ordered with respect to the 'ordinal' field. So
> basically I need to ensure that the RECEIVED relationships returned by the
> query are ordered in terms of nx.ordinal.
>
> My query looks like this so far:
>
> MATCH (h:Country)<-[r:BELONGS_TO]-(u:User)-[:RECEIVED]->(nx:Notification)
> RETURN u.id AS userid, h.code AS homecountry, collect(nx.text) AS
> notifications
>
> How would I go about ensuring that the elements collections within the
> notifications column are ordered in terms of nx.ordinal?
>
> I'm using neo4j 2.0.1
>
> Thanks!
> Raúl.
>
> --
> 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/groups/opt_out.
>



-- 
The best way to ask for Cypher help: http://console.neo4j.org/usage.html

-- 
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/groups/opt_out.

Reply via email to