Create, show, and delete indexes

This page describes how to create, list, and delete search-performance indexes. The following index types are included in this category:

For information about how search-performance indexes are used in Cypher® queries, see Using search-performance indexes.

CREATE INDEX

Creating an index is done with the CREATE …​ INDEX …​ command. If no index type is specified in the create command a range index will be created.

Best practice is to give the index a name when it is created. If the index is not explicitly named, it gets an auto-generated name.

The index name must be unique among both indexes and constraints.

The CREATE INDEX command is optionally idempotent. This mean that its default behavior is to throw an error if an attempt is made to create the same index twice. If IF NOT EXISTS is appended to the command, no error is thrown and nothing happens should an index with the same name or same schema and index type already exist. It may still throw an error if conflicting constraints exist, such as constraints with the same name or schema and backing index type. Introduced in 5.17 An informational notification is instead returned showing the existing index which blocks the creation.

Index providers and configuration settings can be specified using the OPTIONS clause.[1]

However, not all indexes have available configuration settings or more than one provider. In those cases, nothing needs to be specified and the OPTIONS map should be omitted from the query.

Creating an index requires the CREATE INDEX privilege.

A newly created index is not immediately available but is created in the background.

Create a range index

Creating a range index can be done with the CREATE INDEX command. Note that the index name must be unique.

Range indexes have only one index provider available, range-1.0, and no supported index configuration.

Supported predicates

Range indexes support most types of predicates:

Predicate Syntax

Equality check.

n.prop = value

List membership check.

n.prop IN list

Existence check.

n.prop IS NOT NULL

Range search.

n.prop > value

Prefix search.

STARTS WITH

Examples

Create a single-property range index for nodes

The following statement will create a named range index on all nodes labeled with Person and which have the surname property.

Creating a node range index on a single property
CREATE INDEX node_range_index_name FOR (n:Person) ON (n.surname)
Create a single-property range index for relationships

The following statement will create a named range index on all relationships with relationship type KNOWS and property since.

Creating a relationship range index on a single property
CREATE INDEX rel_range_index_name FOR ()-[r:KNOWS]-() ON (r.since)
Create a composite range index for nodes

A range index on multiple properties is also called a composite index. For node range indexes, only nodes with the specified label and that contain all the specified properties will be added to the index.

The following statement will create a named composite range index on all nodes labeled with Person and which have both an age and country property.

Creating a composite node range index on multiple properties
CREATE INDEX composite_range_node_index_name FOR (n:Person) ON (n.age, n.country)
Create a composite range index for relationships

A range index on multiple properties is also called a composite index. For relationship range indexes, only relationships with the specified type and that contain all the specified properties will be added to the index.

The following statement will create a named composite range index on all relationships labeled with PURCHASED and which have both a date and amount property.

Creating a composite relationship range index on multiple properties
CREATE INDEX composite_range_rel_index_name FOR ()-[r:PURCHASED]-() ON (r.date, r.amount)
Create a range index using a parameter

This feature was introduced in Neo4j 5.16.

The following statement will create a named range index on all nodes with a Person label and a firstname property using a parameter for the index name.

Parameters
{
  "name": "range_index_param"
}
Creating a node range index on a single property
CREATE INDEX $name FOR (n:Person) ON (n.firstname)
Create a range index only if it does not already exist

If it is not known whether an index exists or not, add IF NOT EXISTS to ensure it does.

Creating a range index with IF NOT EXISTS
CREATE INDEX node_range_index_name IF NOT EXISTS
FOR (n:Person) ON (n.surname)

The index will not be created if there already exists an index with the same schema and type, same name or both. Introduced in 5.17 An informational notification is instead returned.

Notification
`CREATE RANGE INDEX node_range_index_name IF NOT EXISTS FOR (e:Person) ON (e.surname)` has no effect.
`RANGE INDEX node_range_index_name FOR (e:Person) ON (e.surname)` already exists.

Create a text index

Creating a text index can be done with the CREATE TEXT INDEX command. Note that the index name must be unique.

Text indexes have no supported index configuration and, as of Neo4j 5.1, they have two index providers available, text-2.0 (default) and text-1.0 (deprecated).

Supported predicates

Text indexes only solve predicates operating on STRING values.

The following predicates that only operate on STRING values are always solvable by a text index:

  • STARTS WITH

  • ENDS WITH

  • CONTAINS

However, other predicates are only used when it is known that the property is compared to a STRING:

  • n.prop = "string"

  • n.prop IN ["a", "b", "c"]

This means that a text index is not able to solve, for example, e.g. a.prop = b.prop, unless a type constraint also exists on the property.

Text indexes support the following predicates:

Predicate Syntax

Equality check.

n.prop = 'example_string'

List membership check.

n.prop IN ['abc', 'example_string', 'neo4j']

Prefix search.

STARTS WITH

Suffix search.

ENDS WITH

Substring search.

CONTAINS

As of Neo4j 5.11, the above set of predicates can be extended with the use of type constraints. See the section about index compatibility and type constraints for more information.

Text indexes are only used for exact query matches. To perform approximate matches (including, for example, variations and typos), and to compute a similarity score between STRING values, use semantic full-text indexes instead.

Examples

Create a node text index

The following statement will create a named text index on all nodes labeled with Person and which have the nickname STRING property.

Creating a node text index on a single property
CREATE TEXT INDEX node_text_index_nickname FOR (n:Person) ON (n.nickname)
Create a relationship text index

The following statement will create a named text index on all relationships with relationship type KNOWS and STRING property interest.

Creating a relationship text index on a single property
CREATE TEXT INDEX rel_text_index_name FOR ()-[r:KNOWS]-() ON (r.interest)
Create a text index using a parameter

This feature was introduced in Neo4j 5.16.

The following statement will create a named text index on all nodes with the Person label the favoriteColor STRING property using a parameter for the index name.

Parameters
{
  "name": "text_index_param"
}
Creating a node text index on a single property
CREATE TEXT INDEX $name FOR (n:Person) ON (n.favoriteColor)
Create a text index only if it does not already exist

If it is not known whether an index exists or not, add IF NOT EXISTS to ensure it does.

The following statement will attempt to create a named text index on all nodes labeled with Person and which have the nickname STRING property.

Creating a text index with IF NOT EXISTS
CREATE TEXT INDEX node_index_name IF NOT EXISTS FOR (n:Person) ON (n.nickname)

Note that the index will not be created if there already exists an index with the same schema and type, same name or both. Introduced in 5.17 An informational notification is instead returned.

Notification
`CREATE TEXT INDEX node_index_name IF NOT EXISTS FOR (e:Person) ON (e.nickname)` has no effect.
`TEXT INDEX node_text_index_nickname FOR (e:Person) ON (e.nickname)` already exists.
Create a text index specifying the index provider

To create a text index with a specific index provider, the OPTIONS clause is used. The valid values for the index provider are text-2.0 and text-1.0 (deprecated). The default provider is text-2.0.

Creating a text index with index provider
CREATE TEXT INDEX text_index_with_indexprovider FOR ()-[r:TYPE]-() ON (r.prop1)
OPTIONS {indexProvider: 'text-2.0'}

There is no supported index configuration for text indexes.

Create a point index

Creating a point index can be done with the CREATE POINT INDEX command. Note that the index name must be unique.

Point indexes have supported index configuration, but only one index provider available, point-1.0.

Supported predicates

Point indexes only solve predicates operating on POINT values.

Point indexes support the following predicates:

Predicate Syntax

Property point value.

n.prop = point({x: value, y: value})

Within bounding box.

point.withinBBox(n.prop, lowerLeftCorner, upperRightCorner)

Distance.

point.distance(n.prop, center) < = distance

As of Neo4j 5.11, the above set of predicates can be extended with the use of type constraints. See Index compatibility and type constraints for more information.

To learn more about the spatial data types supported by Cypher, see the page about Spatial values.

Examples

Create a node point index

The following statement will create a named point index on all nodes labeled with Person and which have the sublocation POINT property.

Creating a node point index on a single property
CREATE POINT INDEX node_point_index_name FOR (n:Person) ON (n.sublocation)
Create a relationship point index

The following statement will create a named point index on all relationships with relationship type STREET and POINT property intersection.

Creating a relationship point index on a single property
CREATE POINT INDEX rel_point_index_name FOR ()-[r:STREET]-() ON (r.intersection)
Create a point index using a parameter

This feature was introduced in Neo4j 5.16.

The following statement will create a named point index on all relationships with relationship type STREET and POINT property coordinate using a parameter for the index name.

Parameters
{
  "name": "point_index_param"
}
Creating a relationship point index on a single property
CREATE POINT INDEX $name FOR ()-[r:STREET]-() ON (r.coordinate)
Create a point index only if it does not already exist

If it is not known whether an index exists or not, add IF NOT EXISTS to ensure it does.

Creating a point index with IF NOT EXISTS
CREATE POINT INDEX node_point_index IF NOT EXISTS
FOR (n:Person) ON (n.sublocation)

Note that the index will not be created if there already exists an index with the same schema and type, same name or both. Introduced in 5.17 An informational notification is instead returned.

Notification
`CREATE POINT INDEX node_point_index IF NOT EXISTS FOR (e:Person) ON (e.sublocation)` has no effect.
`POINT INDEX node_point_index_name FOR (e:Person) ON (e.sublocation)` already exists.
Create a point index specifying the index configuration

To create a point index with a specific index configuration, the indexConfig settings in the OPTIONS clause. The valid configuration settings are:

  • spatial.cartesian.min (default value: [-1000000.0, -1000000.0])

  • spatial.cartesian.max (default value: [1000000.0, 1000000.0])

  • spatial.cartesian-3d.min (default value: [-1000000.0, -1000000.0, -1000000.0])

  • spatial.cartesian-3d.max (default value: [1000000.0, 1000000.0, 1000000.0`])

  • spatial.wgs-84.min (default value: [-180.0, -90.0])

  • spatial.wgs-84.max (default value: [-180.0, -90.0])

  • spatial.wgs-84-3d.min (default value: [-180.0, -90.0, -1000000.0])

  • spatial.wgs-84-3d.max (default value: [180.0, 90.0, 1000000.0])

The following statement will create a point index specifying the spatial.cartesian.min and spatial.cartesian.max settings.

Creating a point index with index configuration
CREATE POINT INDEX point_index_with_config
FOR (n:Label) ON (n.prop2)
OPTIONS {
  indexConfig: {
    `spatial.cartesian.min`: [-100.0, -100.0],
    `spatial.cartesian.max`: [100.0, 100.0]
  }
}

Note that the wgs-84 and 3D cartesian settings, which are not specified in this example, will be set with their respective default values.

Create a token lookup index

Two token lookup indexes are created by default when creating a Neo4j database (one node label lookup index and one relationship type lookup index). Only one node label and one relationship type lookup index can exist at the same time.

If a token lookup index has been deleted, it can be recreated with the CREATE LOOKUP INDEX command. Note that the index name must be unique.

Token lookup indexes have only one index provider available, token-lookup-1.0, and no supported index configuration.

Supported predicates

Token lookup indexes are present by default and solve only node label and relationship type predicates:

Predicate Syntax (example)

Node label predicate.

MATCH (n:Label)
MATCH (n)
WHERE n:Label

Relationship type predicate.

MATCH ()-[r:REL]->()
MATCH ()-[r]->()
WHERE r:REL

Token lookup indexes improve the performance of Cypher queries and the population of other indexes. Dropping these indexes may lead to severe performance degradation.

Examples

Create a node label lookup index

The following statement will create a named node label lookup index on all nodes with one or more labels:

Creating a node label lookup index
CREATE LOOKUP INDEX node_label_lookup_index FOR (n) ON EACH labels(n)

Only one node label lookup index can exist at a time.

Create a relationship type lookup index

The following statement will create a named relationship type lookup index on all relationships with any relationship type.

Creating a relationship type lookup index
CREATE LOOKUP INDEX rel_type_lookup_index FOR ()-[r]-() ON EACH type(r)

Only one relationship type lookup index can exist at a time.

Create a token lookup index only if it does not already exist

If it is not known whether an index exists or not, add IF NOT EXISTS to ensure it does.

Creating a node label lookup index with IF NOT EXISTS
CREATE LOOKUP INDEX node_label_lookup IF NOT EXISTS FOR (n) ON EACH labels(n)

The index will not be created if there already exists an index with the same schema and type, same name or both. Introduced in 5.17 An informational notification is instead returned.

Notification
`CREATE LOOKUP INDEX node_label_lookup IF NOT EXISTS FOR (e) ON EACH labels(e)` has no effect.
`LOOKUP INDEX node_label_lookup_index FOR (e) ON EACH labels(e)` already exists.

Creating an index when a conflicting index or constraint exists

Failure to create an already existing index

Create an index on the property title on nodes with the Book label, when that index already exists.

Creating a duplicate index
CREATE INDEX bookTitleIndex FOR (book:Book) ON (book.title)

In this case, the index can not be created because it already exists.

Error message
There already exists an index (:Book {title}).

Using IF NOT EXISTS when creating the index would result in no error and would not create a new index.

Failure to create an index with the same name as an already existing index

Create a named index on the property numberOfPages on nodes with the Book label, when an index with the given name already exists. The index type of the existing index does not matter.

Creating an index with a duplicated name
CREATE INDEX indexOnBooks FOR (book:Book) ON (book.numberOfPages)

In this case, the index cannot be created because there already exists an index with the given name.

Error message
There already exists an index called 'indexOnBooks'.

Using IF NOT EXISTS when creating the index would result in no error and would not create a new index.

Failure to create an index when a constraint already exists

Create an index on the property isbn on nodes with the Book label, when an index-backed constraint already exists on that schema. This is only relevant for range indexes.

Creating a range index on same schema as existing index-backed constraint
CREATE INDEX bookIsbnIndex FOR (book:Book) ON (book.isbn)

In this case, the index can not be created because an index-backed constraint already exists on that label and property combination.

Error message
There is a uniqueness constraint on (:Book {isbn}), so an index is already created that matches this.

Failure to create an index with the same name as an already existing constraint

Create a named index on the property numberOfPages on nodes with the Book label, when a constraint with the given name already exists.

Creating an index with same name as an existing constraint
CREATE INDEX bookRecommendations FOR (book:Book) ON (book.recommendations)

In this case, the index can not be created because there already exists a constraint with the given name.

Error message
There already exists a constraint called 'bookRecommendations'.

SHOW INDEXES

Listing indexes can be done with SHOW INDEXES.

Listing indexes requires the SHOW INDEX privilege.

Examples

Listing all indexes

To list all indexes with the default output columns, the SHOW INDEXES command can be used. If all columns are required, use SHOW INDEXES YIELD *.

Showing all indexes
SHOW INDEXES
Result
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | name                              | state    | populationPercent | type     | entityType     | labelsOrTypes | properties         | indexProvider      | owningConstraint | lastRead                 | readCount |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 3  | "composite_range_node_index_name" | "ONLINE" | 100.0             | "RANGE"  | "NODE"         | ["Person"]    | ["age", "country"] | "range-1.0"        | NULL             | NULL                     | 0         |
| 4  | "composite_range_rel_index_name"  | "ONLINE" | 100.0             | "RANGE"  | "RELATIONSHIP" | ["PURCHASED"] | ["date", "amount"] | "range-1.0"        | NULL             | 2023-03-13T11:41:44.537Z | 1         |
| 16 | "example_index"                   | "ONLINE" | 100.0             | "RANGE"  | "NODE"         | ["Book"]      | ["title"]          | "range-1.0"        | NULL             | 2023-04-10T15:41:44.537Z | 2         |
| 17 | "indexOnBooks"                    | "ONLINE" | 100.0             | "TEXT"   | "NODE"         | ["Label1"]    | ["prop1"]          | "text-2.0"         | NULL             | NULL                     | 0         |
| 14 | "node_label_lookup_index"         | "ONLINE" | 100.0             | "LOOKUP" | "NODE"         | NULL          | NULL               | "token-lookup-1.0" | NULL             | 2023-04-13T08:11:15.537Z | 10        |
| 10 | "node_point_index_name"           | "ONLINE" | 100.0             | "POINT"  | "NODE"         | ["Person"]    | ["sublocation"]    | "point-1.0"        | NULL             | 2023-04-05T16:21:44.692Z | 1         |
| 1  | "node_range_index_name"           | "ONLINE" | 100.0             | "RANGE"  | "NODE"         | ["Person"]    | ["surname"]        | "range-1.0"        | NULL             | 2022-12-30T02:01:44.537Z | 6         |
| 6  | "node_text_index_nickname"        | "ONLINE" | 100.0             | "TEXT"   | "NODE"         | ["Person"]    | ["nickname"]       | "text-2.0"         | NULL             | 2023-04-13T11:41:44.537Z | 2         |
| 12 | "point_index_param"               | "ONLINE" | 100.0             | "POINT"  | "RELATIONSHIP" | ["STREET"]    | ["coordinate"]     | "point-1.0"        | NULL             | NULL                     | 0         |
| 13 | "point_index_with_config"         | "ONLINE" | 100.0             | "POINT"  | "NODE"         | ["Label"]     | ["prop2"]          | "point-1.0"        | NULL             | NULL                     | 0         |
| 5  | "range_index_param"               | "ONLINE" | 100.0             | "RANGE"  | "NODE"         | ["Person"]    | ["firstname"]      | "range-1.0"        | NULL             | 2023-12-13T08:23:53.338Z | 2         |
| 11 | "rel_point_index_name"            | "ONLINE" | 100.0             | "POINT"  | "RELATIONSHIP" | ["STREET"]    | ["intersection"]   | "point-1.0"        | NULL             | 2023-03-03T13:37:42.537Z | 2         |
| 2  | "rel_range_index_name"            | "ONLINE" | 100.0             | "RANGE"  | "RELATIONSHIP" | ["KNOWS"]     | ["since"]          | "range-1.0"        | NULL             | 2023-04-12T10:41:44.692Z | 5         |
| 7  | "rel_text_index_name"             | "ONLINE" | 100.0             | "TEXT"   | "RELATIONSHIP" | ["KNOWS"]     | ["interest"]       | "text-2.0"         | NULL             | 2023-04-01T10:40:44.537Z | 3         |
| 15 | "rel_type_lookup_index"           | "ONLINE" | 100.0             | "LOOKUP" | "RELATIONSHIP" | NULL          | NULL               | "token-lookup-1.0" | NULL             | 2023-04-12T21:41:44.537Z | 7         |
| 8  | "text_index_param"                | "ONLINE" | 100.0             | "TEXT"   | "NODE"         | ["Person"]    | ["favoriteColor"]  | "text-2.0"         | NULL             | NULL                     | 0         |
| 9  | "text_index_with_indexprovider"   | "ONLINE" | 100.0             | "TEXT"   | "RELATIONSHIP" | ["TYPE"]      | ["prop1"]          | "text-2.0"         | NULL             | NULL                     | 0         |
| 18 | "uniqueBookIsbn"                  | "ONLINE" | 100.0             | "RANGE"  | "NODE"         | ["Book"]      | ["isbn"]           | "range-1.0"        | "uniqueBookIsbn" | 2023-04-13T11:41:44.692Z | 6         |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
18 rows

One of the output columns from SHOW INDEXES is the name of the index. This can be used to drop the index with the DROP INDEX command.

Listing specific columns

It is possible to return only specific columns of the available indexes using the YIELD clause:

Returning specific columns for all indexes
SHOW INDEXES
YIELD name, type, indexProvider AS provider, options, createStatement
RETURN name, type, provider, options.indexConfig AS config, createStatement
Result
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name                              | type     | provider           | config                                                                                                                                                                                                                                                                                                                                                                                                                     | createStatement                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| "composite_range_node_index_name" | "RANGE"  | "range-1.0"        | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE RANGE INDEX `composite_range_node_index_name` FOR (n:`Person`) ON (n.`age`, n.`country`)"                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| "composite_range_rel_index_name"  | "RANGE"  | "range-1.0"        | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE RANGE INDEX `composite_range_rel_index_name` FOR ()-[r:`PURCHASED`]-() ON (r.`date`, r.`amount`)"                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| "example_index"                   | "RANGE"  | "range-1.0"        | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE RANGE INDEX `example_index` FOR (n:`Book`) ON (n.`title`)"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| "indexOnBooks"                    | "TEXT"   | "text-2.0"         | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE TEXT INDEX `indexOnBooks` FOR (n:`Label1`) ON (n.`prop1`) OPTIONS {indexConfig: {}, indexProvider: 'text-2.0'}"                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| "index_343aff4e"                  | "LOOKUP" | "token-lookup-1.0" | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE LOOKUP INDEX `index_343aff4e` FOR (n) ON EACH labels(n)"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| "index_f7700477"                  | "LOOKUP" | "token-lookup-1.0" | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE LOOKUP INDEX `index_f7700477` FOR ()-[r]-() ON EACH type(r)"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| "node_point_index_name"           | "POINT"  | "point-1.0"        | {`spatial.cartesian.min`: [-1000000.0, -1000000.0], `spatial.wgs-84.min`: [-180.0, -90.0], `spatial.wgs-84.max`: [180.0, 90.0], `spatial.cartesian.max`: [1000000.0, 1000000.0], `spatial.wgs-84-3d.max`: [180.0, 90.0, 1000000.0], `spatial.cartesian-3d.min`: [-1000000.0, -1000000.0, -1000000.0], `spatial.cartesian-3d.max`: [1000000.0, 1000000.0, 1000000.0], `spatial.wgs-84-3d.min`: [-180.0, -90.0, -1000000.0]} | "CREATE POINT INDEX `node_point_index_name` FOR (n:`Person`) ON (n.`sublocation`) OPTIONS {indexConfig: {`spatial.cartesian-3d.max`: [1000000.0, 1000000.0, 1000000.0],`spatial.cartesian-3d.min`: [-1000000.0, -1000000.0, -1000000.0],`spatial.cartesian.max`: [1000000.0, 1000000.0],`spatial.cartesian.min`: [-1000000.0, -1000000.0],`spatial.wgs-84-3d.max`: [180.0, 90.0, 1000000.0],`spatial.wgs-84-3d.min`: [-180.0, -90.0, -1000000.0],`spatial.wgs-84.max`: [180.0, 90.0],`spatial.wgs-84.min`: [-180.0, -90.0]}, indexProvider: 'point-1.0'}"       |
| "node_range_index"                | "RANGE"  | "range-1.0"        | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE RANGE INDEX `node_range_index` FOR (n:`Person`) ON (n.`surname`)"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| "node_text_index_nickname"        | "TEXT"   | "text-2.0"         | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE TEXT INDEX `node_text_index_nickname` FOR (n:`Person`) ON (n.`nickname`) OPTIONS {indexConfig: {}, indexProvider: 'text-2.0'}"                                                                                                                                                                                                                                                                                                                                                                                                                          |
| "point_index_with_config"         | "POINT"  | "point-1.0"        | {`spatial.cartesian.min`: [-100.0, -100.0], `spatial.wgs-84.min`: [-180.0, -90.0], `spatial.wgs-84.max`: [180.0, 90.0], `spatial.cartesian.max`: [100.0, 100.0], `spatial.wgs-84-3d.max`: [180.0, 90.0, 1000000.0], `spatial.cartesian-3d.min`: [-1000000.0, -1000000.0, -1000000.0], `spatial.cartesian-3d.max`: [1000000.0, 1000000.0, 1000000.0], `spatial.wgs-84-3d.min`: [-180.0, -90.0, -1000000.0]}                 | "CREATE POINT INDEX `point_index_with_config` FOR (n:`Label`) ON (n.`prop2`) OPTIONS {indexConfig: {`spatial.cartesian-3d.max`: [1000000.0, 1000000.0, 1000000.0],`spatial.cartesian-3d.min`: [-1000000.0, -1000000.0, -1000000.0],`spatial.cartesian.max`: [100.0, 100.0],`spatial.cartesian.min`: [-100.0, -100.0],`spatial.wgs-84-3d.max`: [180.0, 90.0, 1000000.0],`spatial.wgs-84-3d.min`: [-180.0, -90.0, -1000000.0],`spatial.wgs-84.max`: [180.0, 90.0],`spatial.wgs-84.min`: [-180.0, -90.0]}, indexProvider: 'point-1.0'}"                            |
| "rel_point_index_name"            | "POINT"  | "point-1.0"        | {`spatial.cartesian.min`: [-1000000.0, -1000000.0], `spatial.wgs-84.min`: [-180.0, -90.0], `spatial.wgs-84.max`: [180.0, 90.0], `spatial.cartesian.max`: [1000000.0, 1000000.0], `spatial.wgs-84-3d.max`: [180.0, 90.0, 1000000.0], `spatial.cartesian-3d.min`: [-1000000.0, -1000000.0, -1000000.0], `spatial.cartesian-3d.max`: [1000000.0, 1000000.0, 1000000.0], `spatial.wgs-84-3d.min`: [-180.0, -90.0, -1000000.0]} | "CREATE POINT INDEX `rel_point_index_name` FOR ()-[r:`STREET`]-() ON (r.`intersection`) OPTIONS {indexConfig: {`spatial.cartesian-3d.max`: [1000000.0, 1000000.0, 1000000.0],`spatial.cartesian-3d.min`: [-1000000.0, -1000000.0, -1000000.0],`spatial.cartesian.max`: [1000000.0, 1000000.0],`spatial.cartesian.min`: [-1000000.0, -1000000.0],`spatial.wgs-84-3d.max`: [180.0, 90.0, 1000000.0],`spatial.wgs-84-3d.min`: [-180.0, -90.0, -1000000.0],`spatial.wgs-84.max`: [180.0, 90.0],`spatial.wgs-84.min`: [-180.0, -90.0]}, indexProvider: 'point-1.0'}" |
| "rel_range_index_name"            | "RANGE"  | "range-1.0"        | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE RANGE INDEX `rel_range_index_name` FOR ()-[r:`KNOWS`]-() ON (r.`since`)"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| "rel_text_index_name"             | "TEXT"   | "text-2.0"         | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE TEXT INDEX `rel_text_index_name` FOR ()-[r:`KNOWS`]-() ON (r.`interest`) OPTIONS {indexConfig: {}, indexProvider: 'text-2.0'}"                                                                                                                                                                                                                                                                                                                                                                                                                          |
| "text_index_with_indexprovider"   | "TEXT"   | "text-2.0"         | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE TEXT INDEX `text_index_with_indexprovider` FOR ()-[r:`TYPE`]-() ON (r.`prop1`) OPTIONS {indexConfig: {}, indexProvider: 'text-2.0'}"                                                                                                                                                                                                                                                                                                                                                                                                                    |
| "uniqueBookIsbn"                  | "RANGE"  | "range-1.0"        | {}                                                                                                                                                                                                                                                                                                                                                                                                                         | "CREATE CONSTRAINT `uniqueBookIsbn` FOR (n:`Book`) REQUIRE (n.`isbn`) IS UNIQUE OPTIONS {indexConfig: {}, indexProvider: 'range-1.0'}"                                                                                                                                                                                                                                                                                                                                                                                                                          |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Note that YIELD is mandatory if the RETURN clause is used. RETURN is not, however, mandatory when the YIELD clause is used.

Listing indexes with filtering

The SHOW INDEX command can be filtered in various ways.

For example, to show only range indexes, use SHOW RANGE INDEXES.

Another more flexible way of filtering the output is to use the WHERE clause. An example is to only show indexes not belonging to constraints.

To show only range indexes that does not belong to a constraint we can combine the filtering versions.

Showing range indexes
SHOW RANGE INDEXES WHERE owningConstraint IS NULL
Result
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | name                              | state    | populationPercent | type    | entityType     | labelsOrTypes | properties         | indexProvider | owningConstraint | lastRead                 | readCount |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 3  | "composite_range_node_index_name" | "ONLINE" | 100.0             | "RANGE" | "NODE"         | ["Person"]    | ["age", "country"] | "range-1.0"   | NULL             | NULL                     | 0         |
| 4  | "composite_range_rel_index_name"  | "ONLINE" | 100.0             | "RANGE" | "RELATIONSHIP" | ["PURCHASED"] | ["date", "amount"] | "range-1.0"   | NULL             | 2023-03-13T11:41:44.537Z | 1         |
| 16 | "example_index"                   | "ONLINE" | 100.0             | "RANGE" | "NODE"         | ["Book"]      | ["title"]          | "range-1.0"   | NULL             | 2023-04-10T15:41:44.537Z | 2         |
| 1  | "node_range_index_name"           | "ONLINE" | 100.0             | "RANGE" | "NODE"         | ["Person"]    | ["surname"]        | "range-1.0"   | NULL             | 2022-12-30T02:01:44.537Z | 6         |
| 5  | "range_index_param"               | "ONLINE" | 100.0             | "RANGE" | "NODE"         | ["Person"]    | ["firstname"]      | "range-1.0"   | NULL             | 2023-12-13T08:23:53.338Z | 2         |
| 2  | "rel_range_index_name"            | "ONLINE" | 100.0             | "RANGE" | "RELATIONSHIP" | ["KNOWS"]     | ["since"]          | "range-1.0"   | NULL             | 2023-04-12T10:41:44.692Z | 5         |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
6 rows

This will only return the default output columns.

To get all columns, use:

SHOW RANGE INDEXES YIELD * WHERE owningConstraint IS NULL

Result columns for listing indexes

The below table contains the full information about all columns returned by the SHOW INDEXES YIELD * command:

Table 1. List indexes output
Column Description Type

id

The id of the index. Default Output

INTEGER

name

Name of the index (explicitly set by the user or automatically assigned). Default Output

STRING

state

Current state of the index. Default Output

STRING

populationPercent

% of index population. Default Output

FLOAT

type

The IndexType of this index (FULLTEXT, LOOKUP, POINT, RANGE, or TEXT). Default Output

STRING

entityType

Type of entities this index represents (nodes or relationship). Default Output

STRING

labelsOrTypes

The labels or relationship types of this index. Default Output

LIST<STRING>

properties

The properties of this index. Default Output

LIST<STRING>

indexProvider

The index provider for this index. Default Output

STRING

owningConstraint

The name of the constraint the index is associated with or null if the index is not associated with any constraint. Default Output

STRING

lastRead

The last time the index was used for reading. Returns null if the index has not been read since trackedSince, or if the statistics are not tracked. Default Output Introduced in 5.8

ZONED DATETIME

readCount

The number of read queries that have been issued to this index since trackedSince, or null if the statistics are not tracked. Default Output Introduced in 5.8

INTEGER

trackedSince

The time when usage statistics tracking started for this index, or null if the statistics are not tracked. Introduced in 5.8

ZONED DATETIME

options

Information retrieved from the OPTIONS map about the provider and configuration settings for an index. If neither is specified when creating the index, this column will return the default values.

MAP

failureMessage

The failure description of a failed index.

STRING

createStatement

Statement used to create the index.

STRING

DROP INDEX

An index can be dropped (removed) using the name with the DROP INDEX index_name command. This command can drop indexes of any type, except those backing constraints. The name of the index can be found using the SHOW INDEXES command, given in the output column name.

DROP INDEX index_name [IF EXISTS]

The DROP INDEX command is optionally idempotent. This means that its default behavior is to throw an error if an attempt is made to drop the same index twice. With IF EXISTS, no error is thrown and nothing happens should the index not exist. Introduced in 5.17 An informational notification is instead returned detailing that the index does not exist.

Dropping an index requires the DROP INDEX privilege.

Examples

Drop an index

The following statement will attempt to drop the index named example_index.

Dropping an index
DROP INDEX example_index

If an index with that name exists it is removed, if not the command fails.

Drop an index using a parameter

This feature was introduced in Neo4j 5.16.

The following statement will attempt to drop the index named range_index_param using a parameter for the index name.

Parameters
{
  "name": "range_index_param"
}
Dropping an index
DROP INDEX $name

If an index with that name exists it is removed, if not the command fails.

Failure to drop an index backing a constraint

It is not possible to drop indexes that back constraints.

Dropping an index backing a constraint
DROP INDEX uniqueBookIsbn
Error message
Unable to drop index: Index belongs to constraint: `uniqueBookIsbn`

Dropping the index-backed constraint will also remove the backing index. For more information, see Drop a constraint by name.

Drop a non-existing index

If it is uncertain if an index exists and you want to drop it if it does but not get an error should it not, use IF EXISTS.

The following statement will attempt to drop the index named missing_index_name.

Dropping an index with IF EXISTS
DROP INDEX missing_index_name IF EXISTS

If an index with that name exists it is removed, if not the command does nothing. Introduced in 5.17 Additionally, an informational notification is returned.

Notification
`DROP INDEX missing_index_name IF EXISTS` has no effect. `missing_index_name` does not exist.

1. Index providers are essentially different implementations of the same index type. Different providers are only available for text indexes.