cypher - Neo4j: Get all relations within a set of nodes -


i have following query:

match (d:document)<-[o:occurs_in]-(a:alias) lower(d.content) contains 'keyword' count(o) degree, order degree desc limit 20 match (a)<-[:known_as]-(ag:agent) return ag; 

i filter document nodes containing keyword , top 20 alias nodes ordered how connected document nodes. after agents connected alias nodes collected , returned.

this gives me set of agent nodes. in addition want relations within set of agent nodes. means returning set of nodes should same. relations in between these nodes should added.

how can archieve without additional query?

here how you'd direct relationships between agent nodes returned original query:

match (d:document)<-[o:occurs_in]-(a:alias) lower(d.content) contains 'keyword' count(o) degree, order degree desc limit 20 match (a)<-[:known_as]-(ag:agent) collect(ag) ags unwind ags ag1 uniwnd ags ag2 match (ag1)-[r]->(ag2) return r; 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo