I am having trouble with a particular cypher query and I am hoping someone can help. I am trying to query different relationship types of a parent so that I can return a response that includes some key/value pairs for id, name, and node label of the parent while also returning an array of children as another key/value pair in the same object returned. The array of children come from the second relationship MATCH set. When I run this, I am getting an amount of elements in that array that is much larger that the relationship with the parent supports (about 100 elements instead of the intended three).
MATCH (n)-[relone:RELATIONSHIP_ONE]->(children_one),
(n)-[reltwo:RELATIONSHIP_TWO]->(children_two)
WHERE n.id='839930493049039430'
RETURN n.id AS id,
n.name AS name,
labels(n)[0] AS type,
{
keystring: {
id: (n.id + '_all'),
count: count(relone)
}
} AS rel_one_representation,
COLLECT({
name : children_two.name
}) AS rel_two_representation
Here is the json output I hope to eventually produce:
{
"id" : "839930493049039430",
"name" : "lorem",
"type" : "epsim",
"rel_one_representation" : {
"keystring" : {
"id" : "839930493049039430_all",
"count" : 7
}
},
"rel_two_representation" : [
{
"name" : "barker"
},
{
"name" : "bird"
},
{
"name" : "tiki"
}
]
}
Thank you in advance for any guidance you can suggest.