Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 119 additions & 18 deletions modules/ROOT/pages/import.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Indexes and constraints are not created during the import.
Instead, you have to add these afterward (see link:{neo4j-docs-base-uri}/cypher-manual/current/indexes/semantic-indexes/full-text-indexes/[Cypher Manual -> Indexes]).

You can use the `--schema` option to create and populate indexes and constraints during the import process.
The option is available in the Enterprise Edition and works only for the `block` format.
The option is available in the Enterprise Edition and works only with `block` format.
See <<indexes-constraints-import, Provide indexes and constraints during import>> for more information.

Vector indexes can take advantage of the incubated Java Vector API for noticeable speed improvements.
Expand Down Expand Up @@ -2208,57 +2208,128 @@ actors-header.csv actors.csv.zip movies-header.csv movies.csv.gz roles-heade

[source, sh]
----
bin/neo4j-admin database import --nodes import/movies-header.csv,import/movies.csv.gz --nodes import/actors-header.csv,import/actors.csv.zip --relationships import/roles-header.csv,import/roles.csv.gz
bin/neo4j-admin database import full --nodes import/movies-header.csv,import/movies.csv.gz --nodes import/actors-header.csv,import/actors.csv.zip --relationships import/roles-header.csv,import/roles.csv.gz
----
====

[role=label--enterprise-edition]
[[indexes-constraints-import]]
== Create/Drop indexes and constraints during import

You can use the `--schema` option to create and populate indexes/constraints during full and incremental import by providing a Cypher script containing `CREATE INDEX|CONSTRAINT` commands.
During an incremental import, you can also use the same option to drop indexes/constraints, provided that the Cypher script contains `DROP INDEX|CONSTRAINT` commands.
[NOTE]
====
Creating and dropping indexes and constraints during the import process is supported only by `block` format.
====

You can use the `--schema` option to create, populate, drop, or change the graph type during import by providing a Cypher script containing the respective Cypher commands, which will be parsed and executed during the import process.
You can specify individual constraint statements, or starting with 2026.05, you can specify a graph type using an `ALTER CURRENT GRAPH TYPE` statement.
For more information on graph types, see link:{neo4j-docs-base-uri}/cypher-manual/current/schema/graph-types/[CypherManual -> `Graph types (Preview)`].

The following table summarizes the supported commands and their availability per import type and version:

The `--schema` option works only for `block` store format.
For incremental import, creating and dropping indexes and constraints are available from 2025.02.
.Supported schema operations per import type and Neo4j and Cypher version
[options="header", width="100%", cols="1,3,2,2"]
|===
| Import type
| Supported commands
| Neo4j version
| Cypher version
.2+| Full import
| `CREATE INDEX\|CONSTRAINT` | 5.24 and later | Cypher 5 & Cypher 25
| `ALTER CURRENT GRAPH TYPE` (only `SET`) | 2026.05 and later | Cypher 25
.3+| Incremental import
| `CREATE INDEX\|CONSTRAINT` | 2025.02 and later | Cypher 5 & Cypher 25
| `DROP INDEX\|CONSTRAINT` | 2025.02 and later | Cypher 5 & Cypher 25
// | `ALTER CURRENT GRAPH TYPE` (`SET`, `ADD`, `DROP`, `ALTER`) | 2026.06 and later | Cypher 25
|===

// TODO: As of 2026.06: For incremental import the option becomes available as of 2026.06, limited to operations ADD, DROP, ALTER. Here you are allowed multiples of these operations.
=== Supported index and constraint types

The import tool supports the following indexes and constraints:
The import tool supports the following index and constraint types:

Supported index types::
* RANGE
* LOOKUP
* POINT
* TEXT
* FULL-TEXT
* VECTOR
+
For more information on these index types, see link:{neo4j-docs-base-uri}/current/indexes/[Cypher Manual -> Indexes].
Comment thread
mnssn marked this conversation as resolved.

Supported constraint types::
Comment thread
renetapopova marked this conversation as resolved.
* *Property uniqueness constraints*: ensure that the combined property values are unique for all nodes with a specific label or all relationships with a specific type.
* *Property existence constraints*: ensure that a property exists either for all nodes with a specific label or for all relationships with a specific type.
* *Property type constraints*: ensure that a property has the required property type for all nodes with a specific label or for all relationships with a specific type.
* *Key constraints*: ensure that all properties exist and that the combined property values are unique for all nodes with a specific label or all relationships with a specific type.

Supported constraint types via graph types::
Comment thread
renetapopova marked this conversation as resolved.
Comment thread
renetapopova marked this conversation as resolved.
* *Node label existence*: ensure that a particular label exists on a node.
* *Relationship source and target label constraints*: ensure that specific relationship types have target and source nodes with specific labels.

For more information on the constraint types, see link:{neo4j-docs-base-uri}/cypher-manual/current/schema/graph-types/set-graph-types/#constraint-types-explained[Cypher Manual -> Constraint types explained].


[[create-drop-indexes-constraints-full]]
=== Create indexes and constraints during full import

You can use the `--schema` option to create and populate indexes/constraints during full import by providing a Cypher script containing `CREATE INDEX|CONSTRAINT` commands to be parsed and executed.

Starting with 2026.05, you can also specify a graph type using an `ALTER CURRENT GRAPH TYPE` statement.
For more information on graph types, see link:{neo4j-docs-base-uri}/cypher-manual/current/schema/graph-types/[CypherManual -> `Graph types (Preview)`].

[NOTE]
====
Full import does not support dropping indexes and constraints.
For graph type it supports only `SET` operations.
====

For example:

[.tabbed-example]
=====
[role=include-with-constraint-statements]
======

._schema.cypher_ script
[source, cypher, role=nocopy]
----
CREATE INDEX PersonNameIndex IF NOT EXISTS FOR (p:Person) ON (p.name);
CREATE CONSTRAINT PersonAgeConstraint IF NOT EXISTS FOR (c:Person) REQUIRE c.age IS :: INTEGER;
CREATE CONSTRAINT PersonAgeRequiredConstraint IF NOT EXISTS FOR (c:Person) REQUIRE c.age IS NOT NULL;
----
This file uses `;` as a separator.
======
[role=include-with-graph-type-statement]
======
Comment thread
renetapopova marked this conversation as resolved.
label:new[Introduced in 2026.05] label:cypher[Cypher 25]

._schema.cypher_ script
[source, cypher, role=nocopy]
----
CYPHER 25
CREATE INDEX PersonNameIndex IF NOT EXISTS FOR (p:Person) ON (p.name);
Comment thread
mnssn marked this conversation as resolved.
ALTER CURRENT GRAPH TYPE SET {
(p: person => { age :: INTEGER NOT NULL })
};
----

This file uses ';' as a separator.
This file uses `;` as a separator.
Only `SET` is supported by the full importer.

Then use the following example commands to run the import:
======
=====

Then, use the following example commands to run the import:

[source, shell, role=noplay]
----
bin/neo4j-admin database import full neo4j --nodes=import/movies.csv --nodes=import/actors.csv --relationships=import/roles.csv --schema=import/schema.cypher
----

[role=label--new-2025.02]
[role=label--new-2026.02]
[[create-drop-indexes-constraints-incremental]]
=== Create and drop indexes and constraints during incremental import

You can use the `--schema` option to create and populate, and drop indexes/constraints during an incremental import by providing a Cypher script containing `CREATE INDEX|CONSTRAINT` and `DROP INDEX|CONSTRAINT` commands to be parsed and executed.
Expand All @@ -2272,6 +2343,7 @@ If you cannot afford a full downtime of your database, split the operation into
See <<incremental-import-stages>> for details.
====


For example:

._schema.cypher_ script
Expand All @@ -2282,10 +2354,44 @@ CREATE CONSTRAINT person_name IF NOT EXISTS FOR (p:Person) REQUIRE p.name IS UNI
DROP CONSTRAINT PersonAgeConstraint IF EXISTS;
CREATE CONSTRAINT movie_title IF NOT EXISTS FOR (m:Movie) REQUIRE m.title IS UNIQUE;
----

This file uses ';' as a separator.

Then use the following example commands to run the import:
// TODO: As of 2026.06:
// [.tabbed-example]
// =====
// [role=include-with-constraint-statements]
// ======
//
// ._schema.cypher_ script
// [source, cypher, role=nocopy]
// ----
// DROP INDEX PersonNameIndex IF EXISTS;
// CREATE CONSTRAINT person_name IF NOT EXISTS FOR (p:Person) REQUIRE p.name IS UNIQUE;
// DROP CONSTRAINT PersonAgeConstraint IF EXISTS;
// CREATE CONSTRAINT movie_title IF NOT EXISTS FOR (m:Movie) REQUIRE m.title IS UNIQUE;
// ----
// This file uses `;` as a separator.
// ======
// [role=include-with-graph-type-statement]
Comment thread
renetapopova marked this conversation as resolved.
// ======
// label:new[Introduced in 2026.05] label:cypher[Cypher 25]
//
// ._schema.cypher_ script
// [source, cypher, role=nocopy]
// ----
// CYPHER 25
// DROP INDEX PersonNameIndex IF EXISTS;
// ALTER CURRENT GRAPH TYPE DROP {
// (p: person => {age :: INTEGER NOT NULL}
// }
// ----
// This file uses `;` as a separator.
// Only `ADD`, `DROP`, `ALTER` is supported by the incremental importer.
//
// ======
// =====

Then, use the following example commands to run the import:

[source, shell, role=noplay]
----
Expand Down Expand Up @@ -2347,9 +2453,4 @@ Violations are reported as JSON object entries, one per line, in `report.json.lo
The import CLI supports the `--report-file` option to override the default output path.
When provided, violations are written to the specified location in the same JSON format.

Each JSON entry includes a `message` field equivalent to the pre-2026.03 format, along with additional fields that provide more detailed information.





Each JSON entry includes a `message` field equivalent to the pre-2026.03 format, along with additional fields that provide more detailed information.