简体   繁体   中英

How to write such a Neo4j query

  1. Suppose I have n persons, and m houses. m is far greater than n .I have the relationships

    stored in Neo4j. Each person can have any number of associated houses. Now, I want a query which will fetch the info like this.

    person-- and its associated houses .

Please let me know , how to write a query for this.

Using cypher:

 Match (n:Person)-[:OWNS]->(m:House)
 Return n, collect(m)

This assumes you label the type of relationship as person OWNS a House. This will return the house nodes as an associated array to each person

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM