# Creation of Index on a Relationship

**URL:** https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457
**Category:** Neo4j Graph Platform
**Tags:** performance, cypher, knowledge-base, index
**Created:** [December 21, 2023, 7:17am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457 "2023-12-21T07:17:22Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![somdeb44](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/somdeb44/32/29618_2.png) [@somdeb44](https://community.neo4j.com/u/somdeb44)
#### Post date: [December 21, 2023, 7:17am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/1 "2023-12-21T07:17:22Z")

</div>

Hi, I am trying to run a Index creation query.  
the query is  
CREATE INDEX ON RELATIONSHIP :transfer\_to (transaction\_date).  
seems this query is not getting executed.  
I would request if anyone can help me to understand how I shall approach to create an index for a relationship.

---

<div class="post-metadata">

### Author: ![hakan.lofqvist1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/hakan.lofqvist1/32/10877_2.png) [@hakan.lofqvist1](https://community.neo4j.com/u/hakan.lofqvist1)
#### Post date: [December 21, 2023, 7:38am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/2 "2023-12-21T07:38:38Z")

</div>

It should be something like this (in neo4j version 5):

```auto
create index my_rel_index if not exists 
    for ()-[r:transfer_to]-() 
    on (r.transaction_date)

```

---

<div class="post-metadata">

### Author: ![somdeb44](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/somdeb44/32/29618_2.png) [@somdeb44](https://community.neo4j.com/u/somdeb44)
#### Post date: [December 21, 2023, 8:03am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/3 "2023-12-21T08:03:02Z")

</div>

Sorry, i forgot mention that i am still using neo4j v3.5

---

<div class="post-metadata">

### Author: ![somdeb44](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/somdeb44/32/29618_2.png) [@somdeb44](https://community.neo4j.com/u/somdeb44)
#### Post date: [December 21, 2023, 8:04am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/4 "2023-12-21T08:04:39Z")

</div>

it throws and error like

Neo.ClientError.Statement.SyntaxError: Invalid input 'e': expected 't/T' (line 1, column 16 (offset: 15))  
"create index Oper if not exists "

---

<div class="post-metadata">

### Author: ![hakan.lofqvist1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/hakan.lofqvist1/32/10877_2.png) [@hakan.lofqvist1](https://community.neo4j.com/u/hakan.lofqvist1)
#### Post date: [December 21, 2023, 8:11am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/5 "2023-12-21T08:11:14Z")

</div>

Relationship indexes were introduced during the neo4j 4.3 if I am not mistaken. Time to upgrade 😉

---

<div class="post-metadata">

### Author: ![hakan.lofqvist1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/hakan.lofqvist1/32/10877_2.png) [@hakan.lofqvist1](https://community.neo4j.com/u/hakan.lofqvist1)
#### Post date: [December 21, 2023, 8:18am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/6 "2023-12-21T08:18:41Z")

</div>

If you have something specific holding you back from upgrading all the way to the lates release, start new threads? Or, if you are contracted with support and everything, reach out to us for further help.

---

<div class="post-metadata">

### Author: ![somdeb44](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/somdeb44/32/29618_2.png) [@somdeb44](https://community.neo4j.com/u/somdeb44)
#### Post date: [December 21, 2023, 9:22am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/7 "2023-12-21T09:22:26Z")

</div>

but in see that when i query Call db.index, i see there are indexes created for relationship with type= relationship\_fulltext.

can you please let me know if we can create any index with type relationship\_fulltext in v3.5?

---

<div class="post-metadata">

### Author: ![somdeb44](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/somdeb44/32/29618_2.png) [@somdeb44](https://community.neo4j.com/u/somdeb44)
#### Post date: [January 12, 2024, 1:17pm UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/8 "2024-01-12T13:17:31Z")

</div>

Hi @hakan.lofqvist1  
I have found out the below query which is creating full text indexs on relationships in v3.5.8

CALL db.index.fulltext.createRelationshipIndex("index\_name",["relationshipname"],["relationship property"]).

can you suggest me a idea how i can delete duplicate relationships depending on the id property of that relationship using the fulltext index?

---

<div class="post-metadata">

### Author: ![FlexDW](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/flexdw/32/22823_2.png) [@FlexDW](https://community.neo4j.com/u/FlexDW)
#### Post date: [January 15, 2024, 5:06am UTC](https://community.neo4j.com/t/creation-of-index-on-a-relationship/65457/9 "2024-01-15T05:06:16Z")

</div>

For nodes, I use this based on the database ID() being an incrementing integer:  
MATCH (n1:MyLabel), (n2:MyLabel)  
WHERE n1.id = n2.id AND ID(n2) \> ID(n1)  
DETACH DELETE n2

I haven't tried for relationships but the same idea should hold.
