neo4j 3.5版本apoc.create.vRelationship不返回边属性

问题描述 投票:0回答:1

这是我的Cypher语句,不知道是因为我的语句写的有问题,还是3.5版本的APOC不支持直接查询边属性,查了官方文档也没找到有没有相关资料

match (first1:ent) where first1.nodeid in ['aab40c4d65d5c0a428ed84dc0109b0c4']
match (first2:ent) where first2.nodeid in ['000415fee2b0272cdcc2439f521b2e2e']
CALL apoc.create.vRelationship(first1,'teninvmerge',{conprop:'11'},first2) YIELD rel 
RETURN rel,rel.conprop

在此输入图片描述

我想获取我直接设置的虚拟边缘的属性

neo4j neo4j-apoc
1个回答
0
投票

该函数或过程不返回属性(如下面来自 neo4j github 的核心代码所示)。您可以使用 startnode、endnode、type 和 id(rel),但不能使用属性。

但是,您可以执行如下操作(这是一个 hack)。 我分配了一个变量 prop = {conprop:'11'} 然后将 prop 作为字典访问,如 prop.conprop。

match (first1:ent) where first1.nodeid in ['aab40c4d65d5c0a428ed84dc0109b0c4']
match (first2:ent) where first2.nodeid in ['000415fee2b0272cdcc2439f521b2e2e']
WITH first1, first2, {conprop:'11'} as prop
CALL apoc.create.vRelationship(first1,'teninvmerge',prop,first2) YIELD rel 
RETURN rel, prop.conprop as conprop, startnode(rel) as startnode , type(rel) as rel_type , endnode(rel) as endnode, id(rel) as id

结果:

╒════════════════╤═════════╤═════════════════════════════════════════════╤═════════════╤═════════════════════════════════════════════╤════╕
│"rel"           │"conprop"│"startnode"                                  │"rel_type"   │"endnode"                                    │"id"│
╞════════════════╪═════════╪═════════════════════════════════════════════╪═════════════╪═════════════════════════════════════════════╪════╡
│{"conprop":"11"}│ "11"    │{"nodeid":"aab40c4d65d5c0a428ed84dc0109b0c4"}│"teninvmerge"│{"nodeid":"000415fee2b0272cdcc2439f521b2e2e"}│-42 │
└────────────────┴─────────┴─────────────────────────────────────────────┴─────────────┴─────────────────────────────────────────────┴────┘

代码取自neo4j:

public String toString() {
        return "VirtualRelationship{" +
               "startNode=" + startNode.getLabels() +
               ", endNode=" + endNode.getLabels() +
               ", type=" + type +
               '}';
    }
© www.soinside.com 2019 - 2024. All rights reserved.