Neo4J
Human Connection is a social network. Using a graph based database which can model nodes and edges natively - a network - feels like an obvious choice. We decided to use Neo4j, the currently most used graph database available. The community edition of Neo4J is Free and Open Source and we try our best to keep our application compatible with the community edition only.
Installation With Docker
Run:
docker-compose up
You can access Neo4J through http://localhost:7474/ for an interactive cypher shell and a visualization of the graph.
Installation Without Docker
Install the community edition of Neo4j along with the plugin Apoc on your system.
To do so, go to releases, choose "Community Server", download the installation files for you operation system and unpack the files.
Download Neo4j Apoc
and drop the .jar file into the plugins folder of the just extracted Neo4j-Server.
Then make sure to allow Apoc procedures by adding the following line to your Neo4j configuration `conf/neo4j.conf`:
dbms.security.procedures.unrestricted=apoc.*
Alternatives
You can download Neo4j Desktop and run locally
for development, spin up a
hosted Neo4j Sandbox instance, run Neo4j in one
of the many cloud options,
spin up Neo4j in a Docker container,
on Archlinux you can install neo4j-community from AUR
or on Debian-based systems install Neo4j from the Debian Repository.
Just be sure to update the Neo4j connection string and credentials accordingly
in backend/.env.
Start Neo4J and confirm the database is running at http://localhost:7474.
Commands
Here we describe some rarely used Cypher commands for Neo4j that are needed from time to time:
Index And Contraint Commands
The indexes and constraints of our database are set in backend/src/db/migrate/store.js.
This is where the magic happens.
If they are missing or not set correctly, the browser search will not work or the database seed for development will not work.
Show Indexes And Contraints
# in browser command line or cypher shell
# show all indexes and contraints
$ :schema
# show all indexes
$ CALL db.indexes();
# show all contraints
$ CALL db.constraints();
Add And Drop Indexes And Contraints
# in browser command line or cypher shell
# create indexes
$ CALL db.index.fulltext.createNodeIndex("post_fulltext_search",["Post"],["title", "content"]);
$ CALL db.index.fulltext.createNodeIndex("user_fulltext_search",["User"],["name", "slug"]);
$ CALL db.index.fulltext.createNodeIndex("tag_fulltext_search",["Tag"],["id"]);
# drop all indexes and contraints
$ CALL apoc.schema.assert({},{},true) YIELD label, key RETURN * ;