Daniel Persson
Daniel Persson

Reputation: 602

Neo4j order by relationship count

I'm new to neo4j and tried to implement a graph with some success. Now I'm trying to make a query ordered by the number of relationships.

For example.

START n=node(*) MATCH (n->[r]->()) ORDER BY Count(r)

is this the right syntax and how do I fire of this question in Java?

Upvotes: 1

Views: 1133

Answers (1)

Mohamed Ismail Mansour
Mohamed Ismail Mansour

Reputation: 1053

The query can be like that

START n=node(*) MATCH n-[r]->()
 RETURN n, r, count(r) 
 ORDER BY count(r)

And you can simply use REST appi to fire the query and execute it in java code.. This link may help you Execute Cypher Queries from Java

Upvotes: 1

Related Questions