Skip to content

Commit 22b84e6

Browse files
NataliaIvakinarenetapopova
authored andcommitted
Add --schema to the neo4j-admin import tool (neo4j#1822)
1 parent 425a273 commit 22b84e6

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

modules/ROOT/pages/tools/neo4j-admin/neo4j-admin-import.adoc

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ These are some things you need to keep in mind when creating your input files:
6464
====
6565
Indexes and constraints are not created during the import.
6666
Instead, you have to add these afterward (see link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/indexes-for-full-text-search[Cypher Manual -> Indexes]).
67+
68+
Starting from Neo4j 5.24, you can use the `--schema` option to create indexes and contraints during the import process.
69+
The option is available in the Enterprise Edition and works only for the block format.
70+
See <<indexes-constraints-import, Provide indexes and constraints during import>> for more information.
6771
====
6872

6973
[[import-tool-full]]
@@ -85,9 +89,9 @@ neo4j-admin database import full [-h] [--expand-commands] [--verbose] [--auto-sk
8589
[--bad-tolerance=<num>] [--delimiter=<char>] [--format=<format>]
8690
[--high-parallel-io=on|off|auto] [--id-type=string|integer|actual]
8791
[--input-encoding=<character-set>] [--max-off-heap-memory=<size>] [--quote=<char>]
88-
[--read-buffer-size=<size>] [--report-file=<path>] [--threads=<num>] --nodes=[<label>[:
89-
<label>]...=]<files>... [--nodes=[<label>[:<label>]...=]<files>...]...
90-
[--relationships=[<type>=]<files>...]... <database>
92+
[--read-buffer-size=<size>] [--report-file=<path>] [--schema=<path>] [--threads=<num>]
93+
--nodes=[<label>[:<label>]...=]<files>... [--nodes=[<label>[:<label>]...=]
94+
<files>...]... [--relationships=[<type>=]<files>...]... <database>
9195
----
9296

9397
=== Description
@@ -287,6 +291,10 @@ If you need to debug the import, it might be useful to collect the stack trace.
287291
This is done by using the `--verbose` option.
288292
|import.report
289293

294+
|--schema=<path> label:new[Introduced in 5.24] label:enterprise[Enterprise edition]
295+
|File in which to store the Cypher schema commands to run as part of the data import.
296+
|
297+
290298
|--skip-bad-entries-logging[=true\|false]
291299
|When set to `true`, the details of bad entries are not written in the log. Disabling logging can improve performance when the data contains lots of faults. Cleaning the data before importing it is highly recommended because faults dramatically affect the tool's performance even without logging.
292300
|false
@@ -416,6 +424,40 @@ bin/neo4j-admin database import full --nodes import/movies_header.csv,import/mov
416424
--relationships import/roles_header.csv,import/roles.csv
417425
----
418426

427+
[role=label--enterprise-edition label--new-5.24]
428+
[[indexes-constraints-import]]
429+
==== Provide indexes and constraints during import
430+
431+
Starting with Neo4j 5.24, you can use the `--schema` option that allows Cypher commands to be provided to create indexes/constraints during the initial import process.
432+
It currently only works for the block format and full import.
433+
434+
You should have a Cypher script containing only `CREATE INDEX|CONSTRAINT` commands to be parsed and executed.
435+
This file uses ';' as the separator.
436+
437+
For example:
438+
439+
[source, cypher, role=nocopy]
440+
----
441+
CREATE INDEX PersonNameIndex FOR (i:Person) ON (i.name);
442+
CREATE CONSTRAINT PersonAgeConstraint FOR (c:Person) REQUIRE c.age IS :: INTEGER
443+
----
444+
445+
List of supported indexes and constraints that can be created by the import tool:
446+
447+
* RANGE
448+
* LOOKUP
449+
* POINT
450+
* TEXT
451+
* FULL-TEXT
452+
* VECTOR
453+
454+
For example:
455+
456+
[source, shell, role=noplay]
457+
----
458+
bin/neo4j-admin database import full neo4j --nodes=import/movies.csv --nodes=import/actors.csv --relationships=import/roles.csv --schema=import/schema.cypher
459+
----
460+
419461

420462
[[import-tool-multiple-input-files-regex-example]]
421463
==== Import data from CSV files using regular expression

0 commit comments

Comments
 (0)