Aerodynamika
Aerodynamika

Reputation: 8413

How to index relationship properties in Neo4J in an easy way

I want to index the existing relationship properties in Neo4J (2.0.1) and also to set up automatic indexing for the ones that will appear in the future.

I found out that it's possible to do that in Neo4J documentation through the legacy auto-indexing as well as the examples of some Java code.

However, as I'm neither an expert in Java, nor want to use "legacy" functionality, I wanted to ask you if there is an easy way to index relationships on a specific property using Cypher command or any other way (rest API?) that wouldn't involve me having to write some Java program and run it (I don't know how to do that).

Upvotes: 5

Views: 12252

Answers (2)

bitoffdev
bitoffdev

Reputation: 3384

Since Neo4j 4.3 (released June 17, 2021), creating relationship property indexes can be done directly with Cypher, as discussed on the Neo4j blog and the 4.3 release notes.

Example from the blog:

CREATE INDEX officerRelationshipProperty
FOR ()-[r:OFFICER_OF]-()
ON (r.role);

Upvotes: 3

Pankaj Katkar
Pankaj Katkar

Reputation: 23

You can't do indexing on relationship. Indexing is done only on nodes.

Upvotes: -3

Related Questions