Vineel
Vineel

Reputation: 1788

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.

Upvotes: 1

Views: 81

Answers (1)

dcinzona
dcinzona

Reputation: 477

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

Upvotes: 4

Related Questions