Where to find dumped data (using dump command in Neo4j Shell) in Neo4j - neo4j

Wondering where to find the dumped file of neo4j dump command. I was running Neo4j v2.1.3 in windows operating system. Please help thanks.

I believe the dump command just outputs to the console, so you need to redirect the output. Something like:
Neo4jShell.bat -c "dump match (n:People)-[:Shared]-(m) return n,m;" > social.connection.db\test2.cql
Edited with the Windows version of the command
For UNIX systems a similar command works:
neo4j-shell -c "dump match (n:People)-[:Shared]-(m) return n,m;" > social.connection.db/test2.cql

Related

Running CQL file in Neo4j

I have a CQL file called Novis.cql. Its somewhere random on my harddrive, but I want to run it in Neo4J to create my graph (it contains 500+ lines of code).
Where do I have to place it? And what command do I have to run nowadays to get it working? I've read and searched for answers, but some of the commands like Neo4jshell dont seem to work any longer...
Any help would be very appreciated!
The cypher-shell tool has been available for a while (starting with version 3.0, if not earlier), and you can use it to execute a Cypher query from a file that can be anywhere in your file system.
For example (on a linux/unix system), a command line like this will work (if you are in the neo4j home directory):
cat /my/full/path/my_code.cql | bin/cypher-shell -u neo4j -p secret
In neo4j 4.0 a new -f option was added to make it simpler:
bin/cypher-shell -u neo4j -p secret -f /my/full/path/my_code.cql

How to Load Cypher File into Neo4j

I have generated a cypher file and want to load it into neo4j.
The only relevant documentation I could find was about loading csv's.
I also tried the shell but it seems to have no effect
cypher-shell.bat -uneo4j -pne04j < db.cql
Copy paste into localhost:7474/browser makes the browser unresponsive.
In the current Neo4j version you can use Cypher Shell to achieve your goal.
From the docs, Invoke Cypher Shell with a Cypher script from the command line:
$ cat db.cql | bin/cypher-shell -u yourneo4juser -p yourpassword
Note that this example is based in a Linux instalation. If you are using Neo4j with Windows, you will need to adjust this command to your needs.
Not sure when this has been added but in the current version (4.4) an alternative way to load a cypher file to NEO4J (GUI) is by dragging and dropping the cypher file over the web browser, which then offers two options, either to add it to the favorites or to paste it in the editor.

Unknown command 'import-cypher', when trying to import into Neo4j database

I'm using neo4j 3.1.1 and I followed this to download and install neo4j-shell-tools:
https://github.com/jexp/neo4j-shell-tools/tree/3.1 but when I do this in my shell:
`Welcome to the Neo4j Shell! Enter 'help' for a list of commands. Please note that neo4j-shell is deprecated and to be replaced by cypher-shell.
NOTE: Remote Neo4j graph database service 'shell' at port 1337
neo4j-sh (?)$ help
Available commands: alias begin call cd commit create cypher dbinfo drop dump env explain export foreach gsh help index jsh load ls man match merge mknode mkrel mv optional paths planner profile pwd return rm rmnode rmrel rollback runtime schema set start trav unwind using with
Use man <command> for info about each command.
Please note that neo4j-shell is deprecated and to be replaced by cypher-shell.
neo4j-sh (?)$ import-cypher
Unknown command 'import-cypher'`
I can't see what is the problem
any suggestions on how to solve this, what have I missed?
Thanks in advance!

neo4j-shell example of running a Cypher script

I need to run a Cypher query against a Neo4J database, from a command line (for batch scheduling purposes).
When I run this:
./neo4j-shell -file /usr/share/neo4j/scripts/query.cypher -path /usr/share/neo4j/neo4j-community-3.1.1/data/databases/graph.db
I get this error:
ERROR (-v for expanded information):
Error starting org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory, /usr/share/neo4j/neo4j-community-3.1.1/data/databases/graph.db
There is a running Neo4J instance on that database (localhost:7474). I need the script to perform queries against it.
NOTE: this is a split of the original question, for the sake of tidiness.
To execute (one or more) Cypher statements from a file while the neo4j server is running, you can use the APOC procedure apoc.cypher.runFile(file or url).
Since you mention "batch scheduling", the Job management and periodic execution APOC procedures may be helpful. Those procedures could, in turn, execute calls to apoc.cypher.runFile.
Okay I just spun up a fresh instance of Neo4j-community-3.1.1 today and ran into the exact same problem. Note that I had already created a database using the bulk import tool, so one might need to make a directory for a database (mkdir data/databases/graph.db) before using a shell.
I believe your problem might be that you have an instance of Neo4j process running against the database you are trying to access.
For me, shutting down Neo4j, and then starting the shell with an explicit path worked:
cd /path/to/neo4j-community-3.1.1/
bin/neo4j stop ## assuming it is already running (may need a port specifier)
bin/neo4j-shell -path data/databases/graph.db
For some reason I thought you could have both the shell and the server running, but apparently that is not the case. Hopefully someone will correct me if I am wrong.

How to change the memory config for the Neo4j-shell command tool of Cypher batch import

I am trying to use neo4j-shell command tool to do Cypher batch import. I followed the instructions described in Import data into your neo4j database from the neo4j-shell command. Here was the command that I ran:
import-cypher -d "," -i c://temp//neo//import.csv -o c://temp//neo//out.csv start n=node:employee_idx(EmpID={emp_id}), m=node:permit_idx(PmtID={pmtid}) create n<-[:Assign{AssID:{assid}}]-m
If there were only 100000 records in import.csv file, it ran perfectly. But if there were 200000 records in import.csv file, I got error: Error occurred in server thread; nested exception is: java.lang.OutOfMemory Error: Java heap space.
How to change the default memory config of this tool?
You need to set the environment variable JAVA_OPTS to appropriate values, e.g. on Linux it can be done using
JAVA_OPTS="-Xmx4G" bin/neo4j-shell

Resources