我有一个Decision
节点,其集合为Tag
:
@NodeEntity
public class Decision {
@Relationship(type = BELONGS_TO, direction = Relationship.OUTGOING)
private Set<Tag> tags;
....
}
根据以下问题[{3}}中描述的问题,我创建了以下查询,以便选择Decision
+它Tags
:
MATCH (parentD)-[:CONTAINS]->(childD:Decision)
WHERE parentD.id = {decisionId}
WITH childD
SKIP 0 LIMIT 100
RETURN childD AS decision,
[ (childD)-[rdt:BELONGS_TO]->(t:Tag) | t ] AS tags
是否可以更改RETURN
语句,以便将tags
置于decision
内(作为decision.tags
)而不是将它们放在同一级别?< / p>
答案 0 :(得分:1)
当然这很简单,它不再是一个节点,而是地图。
MATCH (parentD:Decision)-[:CONTAINS]->(childD:Decision)
WHERE parentD.id = {decisionId}
WITH childD
SKIP 0 LIMIT 100
RETURN childD {.*, tags: [ (childD)-[:BELONGS_TO]->(t:Tag) | t ] } AS decision
这使用地图表达式,您可以通过以下方式构建地图:
variable { .property, .*, foo:"bar", bar:nested-expression }