Neo4j cypher: Store timestamp as a node property - neo4j

When trying to store a timestamp localdatetime() as node property updatedAt:
MERGE (profile:Profile {userId:{id}})
SET profile += {userId:{id}, updatedAt:localdatetime()}
RETURN profile
I'm getting this error:
Current record format does not support TEMPORAL_PROPERTIES.
Please upgrade your store to the format that support requested capability.
I'm running Neo4j 3.4.4 as a Docker container, version, so this error shouldn't be occurring. Is my cypher query wrong?

I was able to fix this with:
Removing all nodes:
MATCH (n) DETACH DELETE n;
Removing all graph.db labels and properties:
sudo rm -rf neo4j/data/databases/graph.db/*.*

Related

How to remove neo4j COMPLETE?

Installing neo4j at arch with yay -S neo4j-community and starting with systemctl start neo4j I open http://localhost:7474/browser/ and execute the demo command create database movies but I get the error
Neo.ClientError.Statement.NotSystemDatabaseError
Unsupported administration command: CREATE DATABASE movies
because of desperation I tried to remove neo4j completely but he still "remembers" my initial password and also still has a reference to graph.db that I have removed manually in the menubar.
Where are the files neo4j stores and does someone have idea to fix the problem with the database creation?

How to create new database in neo4j?

I'm using Linux 16.04 OS. I have installed fresh neo4j. I get referenced exegetic and digitalocean sites.
By default there's graph.db database.
My question is how to create a new database and create nodes and
relation ship between nodes?
As I show in picture default DB name is graph.db.
Since you're using Neo 3.x, to create a new database without removing your existing one, you can simply edit the neo4j.conf file in your conf directory of your $NEO4J_HOME.
Search for dbms.active_database=, which should have the default value of graph.db. Replace it with some other name and start neo4j again. Now, a new database will be created under that directory name. To switch back to your previous db, repeat the steps, just replace your new value with graph.db in the configuration file.
Neo Technology has come with a new Desktop Tool that greatly improves productivity called Neo4J Desktop. You can download it here
Using it you can manage different projects, create different databases, and simply manage them / switch between them, using the GUI.
Really saves a lot of time.
Apparently in Community Edition you only have 1 database, so I used docker containers to create one server per db. Modify the ports + data volume as shown below:
docker run \
--rm \
--publish=8474:7474 --publish=8687:7687 \
--volume=$HOME/neo4j/data2:/data \
--volume=$HOME/Downloads/neo4j/import:/var/lib/neo4j/import \
--name=neo4j \
--env NEO4J_AUTH=neo4j/password \
neo4j:3.4
# Defaults:
# --publish=7474:7474 --publish=7687:7687 \
# --volume=$HOME/neo4j/data:/data \
In the documentation of Neo4j
Community Edition is a fully functional edition of Neo4j, suitable for
single instance deployments. It has full support for key Neo4j
features, such as ACID compliance, Cypher, and programming APIs. It is
ideal for learning Neo4j, for do-it-yourself projects, and for
applications in small workgroups.
So you only have one database instance.
If you want to get started with Neo4j there is a section in the community edition called "jump into code." There is a wizard to tell you how to get started with their language "Cypher."
To create a new Neo4j database in Unix Environment, the following steps are needed:
first, the configuration file of neo4j exists in the following location:
cd /etc/neo4j (ls ---> neo4j.config);
access the file using vim: sudo vim neo4j.config;
edit the following (by pressing i (for insert)):
there is a commented assignment (at the beginning) which is:
#dbms.active_database=graph.db; remove the comment and add the name of the folder containing the database that you want to create and directly add its location before graph.db
i.e: dbms.active_database=new_db/graph.db; press: Esc + :wq (to save the modification)
After executing sudo service neo4j start, you will see that the activated database is new_db/graph.db
if you want to check that everything went fine, follow these steps:
go to: cd /var/lib/neo4j;
execute: ls (you will have certificates, plugins, data, import); then go to: cd data/databases; then execute ls :you will notice that you have the old database (graph.db), and the new folder new_db that contains also the new_created database graph.db
Remarks:
Neo4j is developed for single database use, and all the manipulations are performed on a single database.
If you want to clear the database, you can go to the location of graph.db and erase everything since doing that from neo4j is very difficult and most of times, you will forget to delete dependencies, labels, ...
i.e : say, we want to clear the new created database graph.db that exists in the folder new_db:
we go to : cd ..../new_db;
execute ls (you will have graph.db);
execute: sudo rm -rf graph.db/*;
Last remark, if you want to access the default database, you just recomment the assignment that you edited
The process is a little tricky in case of causal cluster.
First, stop all the neo4j instances across the VMs in your cluster
sudo systemctl stop neo4j
DB location on Linux machines = /var/lib/neo4j/data/databases
To delete existing db : rm -rf /database/graph.db
Edit new DB name under the template
Search for dbms.active_database=, which should have the default value of graph.db . Replace it with a new DB. On the restart, neo4j will automatically create it.
Remember to UNCOMMENT the line.
Unbind all the nodes — this clears the cluster state and forces the node to freshly join the cluster.
neo4j-admin unbind
Now, this is really important and most people are unaware of this.
Now go ahead and start neo4j instances in all the nodes one by one. This should create new DBs across and you’ll see the nodes joining the cluster.
sudo systemctl start neo4j
Check logs using
journalctl -unit=neo4j -r
OR
sudo systemctl status neo4j

Already deleted relationships in Neo4j Database

We got a problem with the neo4j database. I was running this query, after a minute the docker container stopped and the database needed a to be restarted manually.
start r=relationship(*)
match (s)-[r]->(e)
with s,e,type(r) as typ, tail(collect(r)) as coll
WHERE coll <> []
RETURN COUNT(coll)
The only thing that we see in the logging is a lot of deleted relationships. There is no delete query running. It there something wrong with the db/ can it be fixed? The error message is:
Unable to delete relationship[5146889] since it is already deleted.
Version is 3.1.1
Neo is running on docker (swarm). But only a cluster of 1.

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!

How to clean up Neo4j database

I'm a newbie on Neo4j DB, and I want to write a Java function to clean up all of stuff in Neo4j db like nodes, relations, index, label ... but don't have effecting solution.
In current, I must use 3 queries to call to Neo4j server:
+ delete nodes and relations
+ delete constraints
+ delete index
Does Neo4j support to do all of that in just 1 query statement?
Thanks for any suggestion.
To cleanly delete everything, just stop the db, drop the data/graph.db folder completely and restart Neo4j, so
bin/neo4j stop; rm -rf data/graph.db; bin/neo4j start
as a one line command to fulfill your needs.

Resources