Cypher: Single column results

86 views
Skip to first unread message

Luanne Coutinho

unread,
Apr 27, 2012, 2:41:24 PM4/27/12
to ne...@googlegroups.com
Hi,

For a query like this:

start n=node(13), targetPerson=node(17)
match (person)<-[:knows|works_with]-(n)-[?:friend]-(friend)-[?:knows|works_with]-(friendProfile)
return person.name,friendProfile.name

is there a way to transpose this single row result into multiple rows with a single column?

e.g if the result is-
PersonA | PersonB
PersonC | PersonD

can I somehow get:
PersonA
PersonB
PersonC
PersonD

Or could I concatenate the two columns into a delimited one such as:
PersonA,PersonB
PersonC,PersonD

(like a COLLECT)?

Thanks
Luanne

Andres Taylor

unread,
Apr 28, 2012, 4:17:32 AM4/28/12
to ne...@googlegroups.com
Interesting idea. Right now, no you can't. But if you could concatenate lists of stuff, something like this might work:

return collect(person.name) + collect(friendProfile.name)

WDYT?

Andrés

Luanne Misquiita

unread,
Apr 28, 2012, 9:06:53 AM4/28/12
to ne...@googlegroups.com
Yes, that would work. The challenge with this kind of graph is that I've got to go in different directions from the start node to find the result and those paths are difficult to combine and the have optional sub-paths. At the end of the day, I still want person nodes- rows with multiple columns each for a person, with some columns per row possibly null is a bit of a pain to deal with.  

Regards
Luanne

Sent from my iPad

Michael Hunger

unread,
Apr 28, 2012, 9:14:50 AM4/28/12
to ne...@googlegroups.com
Do you run these queries embedded or against the server?

It should be pretty simple to combine them in the client into a single-column stream? Just a nested iterator.


Michael

Luanne Misquiita

unread,
Apr 28, 2012, 9:30:42 AM4/28/12
to ne...@googlegroups.com
Embedded- that's what I'm doing right now, combining on the client side.

-luanne

Sent from my iPad
Reply all
Reply to author
Forward
0 new messages