graph - Finding Nodes with lots of relations pointing to it in neo4j using cypher -


i have neo4j database nodes following structure

[a:article_id] -[r:about_place]-> [l:location] 

now want find article_id,location pairs location has lots of incoming relationships (say > 4)

match ()-[r:about_place]->(n) n,count(r) rel_cnt rel_cnt > 4 return n.name,rel_cnt;  

this works, list of locations need.

list of answers query

but want incomings articles relation also, 5 article ids china has pointing are.

something this,

match (a)-[r:about_place]->(n) a,n,count(r) rel_cnt rel_cnt > 4 return a.title,n.name,rel_cnt; 

but returns 0 rows. im guessing because (a,n) combo used in group clause makes count(r) 1 in each row. saw in talk way count(*) clause works default.

i think solution chain these results , make new query life of me cant figure out how. ideas or links too.

i'm not sure if there's better way this:

match ()-[r:about_place]->(n) n, count(r) rel_cnt rel_cnt > 4 match (a)-[r:about_place]->(n) return a.title,n.name,rel_cnt; 

also, unsolicited notes:

  • you might want use label in query (like match ()-[r:about_place]->(n:location)) better performance
  • neo4j convention has labels in camelcase

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -