I have a following Cypher Pattern Comprehension:
[ (parentD)<-[:DEFINED_BY]-(ch1:Characteristic)<-[v1:HAS_VALUE_ON]-(childD)
WHERE NOT ((ch1)<-[:DEPENDS_ON]-()) AND ch1.type = 'CHILD'
| {characteristicId: toInt(ch1.id), value: v1.value, available: v1.available, totalHistoryValues: v1.totalHistoryValues, description: v1.description, valueType: ch1.valueType, visualMode: ch1.visualMode} ] AS valuedCharacteristics
where parentD
and childD
are the variables from outer query scope.
Right now I need to improve this Pattern Comprehension with additional nodes:
(childD)<-[:DEFINED_BY]-(ch2:Characteristic)<-[v2:HAS_VALUE_ON]-(childD)
WHERE NOT ((ch2)<-[:DEPENDS_ON]-()) AND ch2.type = 'OWN'
in order to be able also return Characteristics
(ch2
) from this query and their values(v2
).
Please help to extend the mentioned query in order to return this information under the same valuedCharacteristics
UPDATED
I have updated comprehension to the following:
[ (parentD)<-[:DEFINED_BY]-(ch1:Characteristic)<-[v1:HAS_VALUE_ON]-(childD)<-[:DEFINED_BY]-(ch2:Characteristic)<-[v2:HAS_VALUE_ON]-(childD)
WHERE
NOT ((ch1)<-[:DEPENDS_ON]-()) AND ch1.type = 'CHILD' AND
NOT ((ch2)<-[:DEPENDS_ON]-()) AND ch2.type = 'OWN' |
{ characteristicId: toInt(ch1.id), value: v1.value, available: v1.available, totalHistoryValues: v1.totalHistoryValues, description: v1.description, valueType: ch1.valueType, visualMode: ch1.visualMode,
childCharacteristicId: toInt(ch2.id), childValue: v2.value, childAvailable: v2.available, childTotalHistoryValues: v2.totalHistoryValues, childDescription: v2.description, childValueType: ch2.valueType, childVisualMode: ch2.visualMode
}
] AS valuedCharacteristics
but right now it always returns empty collection.
I may be wrong but I think the reason is that the following query:
[ (parentD)<-[:DEFINED_BY]-(ch1:Characteristic)<-[v1:HAS_VALUE_ON]-(childD)<-[:DEFINED_BY]-(ch2:Characteristic)<-[v2:HAS_VALUE_ON]-(childD)
can't return the result in some cases.. for example when ch2
is present and ch1
is absent.
(childD)
on both sides of the pattern. Is that intended? – InverseFalconDecision
definesCharacteristic
and then place a value for itself on thisCharacteristic
(in this casetype = 'OWN'
) – alexanoid