Neo4j batch index stream
A writable stream for batch indexing labeled nodes and relations into Neo4j. For example from a csv file or piped output. Before streaming, it will check if a connection to neo4j can be made, and optionally indexes can be set to speed up the inserting process.
Usage
Given the following test.csv
file:
Fabien|likes|Nick
Nick|dislikes|Fabien
Jochem|likes|Nick
Lydia|likes|Fabien
And the following example script, that uses neo4j-batch-index-stream
. You can then run less test.csv | node.js main.js
to pipe the contents of test.csv into main.js, which converts the csv into objects that can be batch inserted in neo4j.
//// main.js var through2 = ;var split2 = ;var Neo4jStream = ; var buildRecords = ; var config = ;var username = configusername;var password = configpassword; // your own password ; var stream = username password "index_key" : "name" "highWaterMark" : 10000; streamindex "Person" "name"; processstdin
Result
Possible errors
Error: Error: connect ECONNREFUSED 127.0.0.1:7474
Neo4j is not running or not available.
Error: {
"errors" : [ {
"message" : "Invalid username or password.",
"code" : "Neo.ClientError.Security.AuthorizationFailed"
} ]
}
You either have the default neo4j/neo4j password or gave incorrect credentials.
Contributing
If you have neo4j running, you can do a simple batch insert with npm test
.
If you feel something is missing, you can open an issue stating the problem and desired result. If code is unclear give me a @mention. Pull requests are welcome.