Neo4j imports data in the following ways:
- Cypher create statement, write a create for each piece of data
- The Cypher load csv statement converts the data into CSV format and reads the data through LOAD CSV.
- neo4j-admin import import
- Official Java API - BatchInserter
- The batch-import tool written by Daniel
- neo4j-apoc load.csv + apoc.load.relationship
Customized development for actual business scenarios:
CSV file import
Import RDF into neo4j database
The difference between neo4j-admin and neo4j-import for data import
Note: There are currently two commonly used methods for batch importing data. There are some differences between the neo4j-import provided by the new version and the neo4j-admin import upgraded from the old version, but there is not much difference in the efficiency of importing data. different.
neo4j-admin parameter
usage: neo4j-admin import [--mode=csv] [--database=<name>] //模式,默认csv
[--additional-config=<config-file-path>]
[--report-file=<filename>]
[--nodes[:Label1:Label2]=<"file1,file2,...">] //实体文件
[--relationships[:RELATIONSHIP_TYPE]=<"file1,file2,...">] // 关系文件
[--id-type=<STRING|INTEGER|ACTUAL>]
[--input-encoding=<character-set>] // 编码格式
[--ignore-extra-columns[=<true|false>]] // 忽略多余列参数
[--ignore-duplicate-nodes[=<true|false>]] // 忽略重复节点参数
[--ignore-missing-nodes[=<true|false>]] // 忽略丢失的节点参数
or
bin/neo4j-import [--into]
[--id-type=<STRING|INTEGER|ACTUAL>]
[--nodes[:Label1:Label2]=<"file1,file2,...">] //实体文件
[--relationships[:RELATIONSHIP_TYPE]=<"file1,file2,...">] // 关系文件
Neo4j multi-library switching
- Method 1: Because Neo4j’s import can only import a non-existing db, when you want to create multiple libraries, you need to switch. The default library of Neo4j is graph.db, in ./conf/neo4j.conf can be modified
# Neo4j configuration
#
# For more details and a complete list of settings, please see
# https://neo4j.com/docs/operations-manual/current/reference/configuration-settings/
#*****************************************************************
# The name of the database to mount
#dbms.active_database=graph.db
- Method 2: To switch multiple libraries, reconnect the new library to the default library graph.db, and then restart Neo4j
//软连接
cd ./data/databases/
ln -s graph_kg.db graph.db
//重启neo4j
cd $NEO4j_HOME/bin
./neo4j restart
// 删除软连接
ln-s test_chk test_chk_ln
rm -rf ./test_chk_ln