Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all indexes in neo4j?

I want to delete all indexes that exist using cypher in a bulk can it be done? I am using neo4j 3.4.7.

DROP INDEX  ON :Label(attributename)

Does it replace existing indexes if I create the same index in a later stage?

like image 372
Abdullah Al Noman Avatar asked Oct 01 '18 14:10

Abdullah Al Noman


2 Answers

A quick way to drop all indexes and constraints is to use the APOC procedure apoc.schema.assert, as follows:

CALL apoc.schema.assert({},{},true) YIELD label, key
RETURN *

The procedure is mainly for ensuring that the DB has the indexes and constraints passed in the first 2 maps, but the third parameter determines whether any other indexes and constraints are dropped. In the above query, the first 2 maps are empty, so the end result is that all indexes and constraints are dropped.

like image 69
cybersam Avatar answered Sep 28 '22 08:09

cybersam


For release 3.x your can to use built-in procedures Neo4j to delate what index your want. From web browser your can send Cipher query:

CALL db.indexes() - List all indexes in the database.

CALL db.index.fulltext.drop() -Drop the specified index.

or CALL db.index.explicit.drop() - Remove an explicit index - YIELD type,name,config

All possible built-in procedures and parameter for last version here User management for Neo4j

old style do it with CIPHER :

DROP INDEX ON :labelOfNode(propertyOfNode)

CREATE INDEX ON :labelOfNode(propertyOfNode)

like image 26
abmerday Avatar answered Sep 28 '22 06:09

abmerday