Node disappears after restart server. Neo4j 3.0 Cypher 3 - neo4j

I'm trying to add a node to my base, but every time I restart the server, the node disappears along with their relationships.
I started my base by importing a CSV using the ./neo4j-import script in the bin folder. The node in question is a node that connects to all subgraphs of my base (like a root node), turning the base into a connected graph.
I already added through the shell (./neo4j-shell) through the web application and using python (using from neo4j.v1 driver import GraphDatabase), in all cases when I restart the server, the node disappears.
The command I am using in all approaches is this:
neo4j-sh (?)$ create(r:PDB{name: 'root', resolution: 'less than 2.0', method: 'x-ray diffraction'});
neo4j-sh (?)$ match(r:PDB{name:'root'}) match(p:PDB_FILE) merge(r)-[:HAS_PDB]->(p);
In the latest attempt used differently (using commit):
neo4j-sh (?)$ begin
neo4j-sh (?)$ create(r:PDB{name: 'root', resolution: 'less than 2.0', method: 'x-ray diffraction'});
neo4j-sh (?)$ match(r:PDB{name:'root'}) match(p:PDB_FILE) merge(r)-[:HAS_PDB]->(p);
neo4j-sh (?)$ commit
But without success.
I'm using version 3.0. * of Neo4j, Cypher 3.0, Ubuntu 4.14 server.

I have no idea on why this is happening to you, but what I would definitely try is using the super batch importer for huge datasets: neo4j-import. There is some instruction on how to use the tool in neo4j documentation.
To use the tool you have to put your data in special formats, individual csv files each corresponding to a type of node or a type of edge in your dataset. It is well explained in the given link, and, even though it does not explain why this is happening to you, it is surely worth a try.
Another things that you could try are:
to install neo4j in another machine. Maybe there is some weird problem with your installation/your system;
try another version of neo4j. I'm not totally aware, but I imagine the latter 2.X.X versions should be more stable than the newer ones, as Neo4j v3 has been release recently. It is easy to install any version using this debian repositories (via apt-get in Ubuntu).

Related

Neo4J crashes after installing APOC plugin

I'm trying to install the APOC Full jar file (4.2.0.6) to my Neo4J instance that's running in a Google Compute VM. To do so, I've installed the JAR file from GitHub releases to the /plugins folder. Each time I restart or run the environment it crashes with the following output to logs:
"Some jar procedure files (apoc-4.2.0.6-all.jar) are invalid, see log for details."
There's really no additional details provided...
If I copy the default APOC Core library found withing /labs, it works. I've tried to download this same file from Github and it fails. I've verified that the same user/group permissions are applied to the downloaded file as well.
Any ideas?
This usually happens for two reasons:
First is version mismatch. You can check which version you should use based on the version matrix, which is available at: https://github.com/neo4j-contrib/neo4j-apoc-procedures#version-compatibility-matrix. Unfortunately, it is not always up to date, but the APOC versions are if I understand correctly:
APOC 4.1.x.x -> Neo4j 4.1.x
APOC 4.2.x.x.-> Neo4j 4.2.x
APOC 4.3.x.x -> Neo4j 4.3.x
If I had to guess, you are probably using Neo4j 4.3 or 4.1 and using an APOC that is designed to work with Neo4j 4.2.
The other issue is that sometimes you have multiple APOC plugin files in the plugin folders, so that will also crash Neo4j.

'authenticate' missing from py2neo

I have a smoothly running python project where I use the line
from py2neo import Node, Relationship, Graph, authenticate, cypher
However, when I moved the files to another machine and tried to run them there, it turned out that 'authenticate' couldn't be imported. And indeed, it doesn't show up under dir(py2neo) in terminal mode.
Python 2.7.13 on both machines. How can that be possible?
From https://github.com/neo4j-contrib/neo4j_doc_manager/issues/76#issuecomment-446290239
You could try:
graph = Graph(host=HOST, auth=(USER, PASS))
and remove authenticate from import line

uninstall and reinstall neo4j

On ubuntu 16.04, when trying to uninstall neo4j I typed:
sudo apt-get purge neo4j*
However, the neo4j folder and all of the data still exist in
/var/lib/neo4j
Secondly, I tried to just install the newest version using:
sudo apt-get install neo4j
and when I checked the version from the commandline I got:
neo4j 3.3.4
This is what I want, but when I start the service and check the version in the web application (http://localhost:7474/browser/), it says that the neo4j version is still 3.1.4.
So, basically I would like to completely remove neo4j, and download the newest version. What is the recommended way of doing this in ubuntu 16.04.
I'm new to neo4j, so I'm sure I'm missing something. Thanks for your help.
I followed the instructions here and they really helped.
Specifically, I deleted my old neo4j folder located in /var/lib/, and in it's place, I put the new version (which was downloaded from the link above and the top folder was renamed "neo4j"). I'm rebuilding my database from scratch, so I wasn't concerned about keeping any of the data I had previously (although maybe you could just copy it over to the new neo4j folder, I don't know).
I started the neo4j service by typing
/var/lib/neo4j/bin/neo4j start
and everything was brand new and seemed to be working. Part of the reason I did a fresh install was because I could not understand how to upgrade based on the documentation. I'll have to look into that more.
I also added the jar file for the corresponding apoc procedures to my plugins folder (/var/lib/neo4j/plugins), and adjusted the neo4j conf file (var/lib/neo4j/conf/neo4j.conf) accordingly:
dbms.security.procedures.unrestricted=apoc.*
and apoc procedures are now being recognized, which is fantastic.
Perhaps there is a better way to have done this, but things seem to be working so far. My database is small right now, so I can build it from scratch easily. Let me know if there is a better way to go about it.
well, I have tried the method above and it did not work. Since the main purpose is to use the verison 4.x.x of neo4j, I tried anothor way to reach the same effect.
At first, download the neo4j-community-4.x.x and put it in someplace where you want, then open the config/neo4j.conf file and change some configuration as follows:
dbms.connector.bolt.listen_address=:7688
dbms.connector.http.listen_address=:7475
After that, start the neo4j by running neo4j start and you shall access the neo4j from browser at localhost:7475, it did work for me. As for the old version, just let it go.

NEO4J 3.1.1 Load CSV

I have been using Neo4j for several months now and am getting pretty exasperated.
It appears that every new version breaks the previous one.
I have multiple Cypher Load scripts that I can no longer run via the command line.
I can run the following from the Browser:
USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///person.csv" AS csvLine
MERGE (p:Person {sysurn : csvLine.urn})
ON CREATE SET p.dob = trim(csvLine.dob)
ON CREATE SET p.forename = trim(csvLine.forename)
ON CREATE SET p.surname = trim(csvLine.surname );
Previously in version 3.0.3 (Community Edition) I ran the following:
java -cp "C:\Program Files\Neo4j CE 3.0.3\bin\neo4j-desktop-3.0.3.jar" org.neo4j.shell.StartClient -file "D:/nosql/Load data/load_person.cql"
This no longer works in 3.1.1:
java -cp "C:\Program Files\Neo4j CE 3.1.1\bin\neo4j-desktop-3.1.1.jar" org.neo4j.shell.StartClient -file "D:/nosql/Load data/load_person.cql"
I get a Java Error. The general consensus is to run the full .tar version, so I installed that.
I can now run the Cypher from the browser or using cypher-shell. However this is of no use as there is no way to call an external script, so I have to do this for possibly hundreds of scripts.
Recommendation is to use ne04j-shell (now deprecated!)
I try neo4j-shell. This doesn't accept spaces in the path!
I move the file and try to run the following:
"C:\Program Files\neo4j-community-3.1.1\bin\neo4j-shell" -path "D:/nosql/neoDB/databases/graph.db" -config "neo4j.conf" -file "D:/nosql/Loaddata/load_person.cql"
I get the following error:
ERROR (-v for expanded information):
Error starting org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory,
D:\nosql\neoDB\databases\graph.db
I have tried various combinations including adding the host name as prompted:
non-JRMP server at remote endpoint
I try adding the -config param, however this again doesn't allow spaces!
With every new version it seems to get more difficult to actually import data into Neo4j.
My question is, Is it possible in version 3.1.1 to run more than one cypher script at a time without manually running every one?
Is it possible to use neo4j-shell in version 3.1.1?
Try using the APOC procedure apoc.cypher.runFile from within cypher-shell. Here is an example (with a file URL formatted for Windows):
CALL apoc.cypher.runFile("file:d:/nosql/Load data/load_person.cql");
If the space in the path still presents problems, you could rename the "Load data" folder to "LoadData" and modify the above query accordingly.
Well I have managed to find a workaround.
Install neo4j 3.1.1
Create a database
Uninstall Neo4j
Install neo4j 3.0.8
Run my Cypher scripts
e.g. java -cp "C:\Program Files\Neo4j CE
3.0.8\bin\neo4j-desktop-3.0.8.jar" org.neo4j.shell.StartClient -file "D:/nosql/Load data/load_person.cql"
uninstall neo4j
install neo4j 3.1.1
I don't think this is going to cut it in a production environment though :)

Neo4j 2.3.1 not releasing handles on import files

After upgrading from Neo4j 2.2.5 to Neo4j 2.3.1 on Windows Server 2012 R2 with Java 8.45, we encountered a problem with file handles. When running the command shown at the bottom of this post using either the web interface or neo4jshell.bat, the cypher completes successfully and a process monitor trace confirms that Java successfully closed the file. However, I am unable to move that csv file because the file is open in another process. Handle.exe confirms that Java still has a read-write handle on that file.
When I run the same process against a Neo4j 2.2.5 graph on the same machine with the same file, Java does not retain the read-write handle on the csv file. We will need to revert to 2.2.5 until this issue is resolved. The only application change we made during the upgrade from 2.2.5 to 2.3.1 was to accommodate the new file reference format (file:///x://filename.csv vs. file:x:/filename.csv).
Are there other actions we can take short of restarting the service or stopping and starting the drive to force Java to close this file? I understand that Neo4jShell.bat is deprecated in favor of the powershell commands, but ultimately the issue is that Java is retaining the file handle, so changing the method of delivering the cypher command can't improve the way Java is handling the csv file. I've run the same cypher from both the web interface and neoj4shell.bat and gotten the same result.
USING PERIODIC COMMIT 3000
LOAD CSV WITH HEADERS
FROM "file:///x://filename.csv"
AS line
MATCH (a:node {id : line.id}), (b:othernode {id : line.other_id})
WITH a, b
WHERE shortestPath((a)-[:PREVIOUS]->(b)) is null
CREATE (a)-[:PREVIOUS]->(b);

Resources