Neo4j Cypher模式理解为对象属性

时间:2017-07-16 16:47:31

标签: neo4j cypher

我有一个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>

1 个答案:

答案 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 }