Skip to content

Instantly share code, notes, and snippets.

@drochetti
Created August 31, 2012 19:42
Show Gist options
  • Save drochetti/3558029 to your computer and use it in GitHub Desktop.
Save drochetti/3558029 to your computer and use it in GitHub Desktop.
Neo4j Cypher query
query.append("START activity = node:__types__(className={activityClass}) ")
// .append("MATCH (activity)-[*1..2]->(source), ")
// .append("(source)<-[:HAS_SOURCE]-(lastActivities) ")
.append("MATCH (activity)-[*1..2]->(source)<-[:HAS_SOURCE]-(lastActivities) ")
.append("WHERE source.__type__ in {sourceTypes} ")
.append("RETURN source as source, COLLECT(lastActivities) as activities ")
// .append("ORDER BY activity.when DESC LIMIT 20"); why can't I use activity anymore? because of second match
.append("LIMIT 20");
@jexp
Copy link

jexp commented Aug 31, 2012

You cannot use activity anymore because you aggregated on source, so the activities are only in the list. What you want is to sort and limit the collection, which is planned in cypher but there is no implementation date yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment