# Apoc.merge.relationship() creates duplicates

**URL:** <https://community.neo4j.com/t/apoc-merge-relationship-creates-duplicates/46807>\
**Category:** Cypher\
**Tags:** apoc, cypher\
**Created:** [November 1, 2021, 7:11pm UTC](https://community.neo4j.com/t/apoc-merge-relationship-creates-duplicates/46807 "2021-11-01T19:11:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![armensanoyan](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/armensanoyan/32/17805_2.png) [@armensanoyan](https://community.neo4j.com/u/armensanoyan)\
**Post date:** [November 1, 2021, 7:11pm UTC](https://community.neo4j.com/t/apoc-merge-relationship-creates-duplicates/46807/1 "2021-11-01T19:11:24Z")

</div>

Hi! I am trying to create relationship between two nodes using apoc.merge.relationship, but it creates two same relationships, which I can see by search. I hope someone can show me what is wrong with my cypher query

```auto
UNWIND [{ 
  color:'#82abd1', direction:'true', id:'q', index:0, linkType:'a', 
  source:'46166.a690c888-e3d5-41ed-8469-79a88cce8388', status:'approved',  
  target:'46163.a690c888-e3d5-41ed-8469-79a88cce8388', type:'Applies for', value:2 
}] AS newLink
        MATCH 
          (fNode:Node {id: newLink.source}),
          (sNode:Node {id: newLink.target})
        CALL apoc.merge.relationship(
          fNode, 
          'Label', 
          {id: newLink.id}, 
          apoc.map.clean(newLink, ['id','type'],[]), 
          sNode, 
          apoc.map.clean(newLink, ['id','type'],[])
        )
        YIELD rel
        RETURN DISTINCT 'true';

```

---

<div class="post-metadata">

**Author:** ![armensanoyan](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/armensanoyan/32/17805_2.png) [@armensanoyan](https://community.neo4j.com/u/armensanoyan)\
**Post date:** [November 2, 2021, 2:50am UTC](https://community.neo4j.com/t/apoc-merge-relationship-creates-duplicates/46807/2 "2021-11-02T02:50:59Z")

</div>

The problem was that I was searching for relationship without specifying nodes

```auto
match (m)-[p]-(n) return p

```

so it found same relationship for both m and n. To avoid this I had to specify at least one of nodes

```auto
match (m {name:'firstNode'})-[p]-(n) return p

```
