# Copy properties to virtual nodes

**URL:** <https://community.neo4j.com/t/copy-properties-to-virtual-nodes/35370>\
**Category:** Procedures & APOC\
**Tags:** apoc, cypher\
**Created:** [March 16, 2021, 6:25pm UTC](https://community.neo4j.com/t/copy-properties-to-virtual-nodes/35370 "2021-03-16T18:25:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mike/32/334_2.png) [@mike](https://community.neo4j.com/u/mike)\
**Post date:** [March 16, 2021, 6:25pm UTC](https://community.neo4j.com/t/copy-properties-to-virtual-nodes/35370/1 "2021-03-16T18:25:41Z")

</div>

Hi,

I want to return virtual nodes and relationships by grouping on unique node properties. In our case this is to visualise/API data relating to single real-world entities: companies and people, using the company name and officer's data of birth to group by.

However, I can't bring through all the original node's properties in the final output?

I found this example which does pretty much want I need and have adjusted it to:

> **[Neo4J and Virtual Nodes/Relationships - DZone](https://dzone.com/articles/neo4j-and-virtual-nodesrelationships)**
>
> This article takes a look at Neo4j and virtual nodes and relationships. Look at definitions, the problem of visualizing the raw data, the solution, and more!

```auto
//Match officer surname, forename, dob
MATCH (c:Company)-[io:IS_OFFICER]->(o:Officer)
WHERE o.surname = "OATEN" AND o.forenames STARTS WITH "MICHAEL" AND o.partialdateofbirth IS NOT NULL

//Collect distinct company names and dob's
WITH collect(distinct c.name) as names, collect(distinct o.partialdateofbirth) as dobs

//Group by distinct company name and dob's
WITH [cname IN names | apoc.create.vNode(['Company'],{name:cname})] as nNodes,
     [dobname IN dobs | apoc.create.vNode(['Officer'],{dob:dobname})] as dNodes
WITH apoc.map.groupBy(nNodes, 'name') AS nvs,
     apoc.map.groupBy(dNodes, 'dob') AS dvs

//Repeat original query to make all properties available     
MATCH (c:Company)-[io:IS_OFFICER]->(o:Officer)
WHERE o.surname = "OATEN" AND o.forenames STARTS WITH "MICHAEL" AND o.partialdateofbirth IS NOT NULL
WITH nvs, dvs, io, c, o

RETURN
nvs, dvs, apoc.create.vRelationship(nvs[c.name], 'IS_OFFICER', io{.*}, dvs[o.partialdateofbirth]) AS rel
LIMIT 100

```

 ![vNodes1](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/e/4/e4d53cc43fe55a1f7408ee52d65edd2f67eff751.jpeg)

The query is doing its main job of grouping by distinct company name and distinct date of birth and the virtual relationship is also correct; and has all the properties from the actual relationship.

But how do I add all the original Officer properties and Company properties to their virtual equivalents?

Thanks in advance for any help
