neo4jneo4j-apoc

The neo4j 3.5 version apoc.create.vRelationship does not return edge attributes


Here's my Cypher statement:

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

enter image description here

How do I get the properties of the virtual edge I set directly?

I don't know if the issue is because my statement is written in a problem, or if the 3.5 version of APOC doesn't support direct query of edge attributes. I checked the official documentation and didn't find any relevant information.


Solution

  • It is actually possible to get properties of virtual nodes and relationships, as noted in the Virtual Nodes & Relationships doc page. Neo4j 3.5 is ancient, and I am not able to determine easily if the functions will work in that version. But they should at least work in neo4j version 4.1+.

    Note that in some cases a regular Cypher function will work as well (e.g., these are verified to work in version 5.x: ID(vnode) and TYPE(vrel)) . But that may depend on the version of neo4j you are using, so it is probably best to stick with the documented APOC functions if you are working with older versions that support them).

    For example, at least in neo4j 4.1+, this should work:

    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, apoc.any.property(rel, 'conprop') AS conprop