I have a graph of Restaurants that are located in different plazas
I'm using the following statement but it's returning all the properties from Plaza and Restaurant
MATCH r=(p:Plaza)-[:in_plaza]->(rs:Restaurant)
WITH COLLECT(r) AS rs
CALL apoc.convert.toTree(rs) yield value
RETURN value
How I can only return certain properties instead of the whole object property same as when i do
MATCH (p:Plaza)-[:in_plaza]->(rs:Restaurant) return p.name as plaza, rs.name as restaurant only returns these two properties
nodes: map of list, a key is the name of the label, value is a list of properties that can be included or excluded. e.g nodes:{LABEL:<[prop1, prop2]/[-prop1, -prop2]>}
MATCH r=(p:Plaza)-[:in_plaza]->(rs:Restaurant)
WITH COLLECT(r) AS rs
CALL apoc.convert.toTree(rs, {
nodes: {Plaza: ['name'], Restaurant: ['name']}
}) yield value
RETURN value
Thanks, It worked, however, i had to pass the second a required second parameter as boolean (lowercase/uppercase relationship names)
MATCH r=(p:Plaza)-[:in_plaza]->(rs:Restaurant) WITH COLLECT(r) AS rs CALL apoc.convert.toTree(rs, true, { nodes: {Plaza: ['name'], Restaurant: ['name']} }) yield value RETURN value
Hello @melgamal, I've fallen into the same need and applied your query that worked for me, thanks by the way for sharing. However in the response I still get the _type and _id params. Did you manage to remove it as well from the response. Thanks