简体   繁体   中英

neo4j cypher, return fields instead of nodes when collecting

Given the following query

match (a)-->(b)-->(c)
where id(a) = 0
return b.name, collect(c) as cs

How it's possible to return a collection composed of only a couple of fields, instead of the whole nodes?

A single field is easy:

match (a)-->(b)-->(c)
where id(a) = 0
return b.name, collect(c.fieldName) as cs

For multiple field names, maybe concatenate them?

match (a)-->(b)-->(c)
where id(a) = 0
return b.name, collect(c.fieldName1 + delimiter + c.fieldName2) as cs
match (a)-->(b)-->(c)
where id(a) = 0
return b.name, collect( { field1: c.field1, field2: c.field2 } ) as cs

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