Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-12-2018 05:37 AM
Hello. I have the following piece of graph:
As you can see, the red nodes are siblings connected by relationships, NEXT and NEXT_SIBLING; moreover, the first and last child are connected to the father by FIRST_CHILD_OF and LAST_CHILD_OF.
My goal is to find a way to store into a string "A B C D" with the right order.
This is an instance of the problem, because I cannot predict the number of children, that in this case are 4.
What I tried in the RETURN is the following:
apoc.text.join( (COLLECT(TRIM(words.text))), " " )
where words is a node. Unfortunately, the words are not ordered, probably I need to take advantage of the edges in some way.
Could you please suggest a solution?
Thanks.
11-12-2018 12:29 PM
Maybe sorting children by the path length.
match path=(father: Father)-[:FIRST_CHILD_OF]-()-[:NEXT_SIBLING*0..]-(children)
with children.text as text
order by length(path)
with apoc.text.join(collect(trim(text)), " " ) as text
return text
All the sessions of the conference are now available online