A B C D E F G H I J K L M N O P Q R S T U V W X Z
Na Ne Nf

Neo4j

Neo4j is a Graphdatabase that can be queried using the query language CYPHER. It can be used for multiple kind of projects requiring connected datasets or graph operations.

Advantages

    • Comes with a free community version that can do a lot of things
    • CYPHER is intuitive and easy to learn
    • Comes with multiple options to view, manipulate and export graphs
    • Comes with a desktop version for local usage

Disadvantages

    • Community version does not include access management for single users
    • Documentation is huge but not always helpful

Using neo4j with docker

neo4j offers an official docker image here: https://hub.docker.com/_/neo4j

With this image, neo4j can be configured in docker-compose:

services:
  neo4j:
    image: neo4j
    container_name: neo4j
    ports:
      - "7687:7687"
      - "7474:7474"
      - "7473:7473"
    volumes:
      - ../neo4j/data:data
      - ../neo4j/logs:logs
      - ../neo4j/import:/var/lib/neo4j/import
    environment:
      - NEO4j_dbms_connector_bolt_listen__address=0.0.0.0:7687
volumes:
  neo4j:

Explaination:

image: Uses the image called neo4j from Dockerhub
container_name: The container can be referenced by this name, which makes it easier to maintain
ports: neo4j uses 3 ports in the container that need to be mapped to the localhost. On port 7687 other apps (e.g. a custom web app) can connect using the BOLT-Protocol. Port 7474 enables http communication and also offers a graphical browser for the database. Port 7373 is for https connection.
volumes: within the container there will be various folders some of which we need to access to use the database. Also we want to sustain data even if the container shuts down. We do this by declaring a volume called „neo4j“ on the bottom. When first executing, this will create a volume called „neo4j“ on the local machine. This volume will then be mounted in the docker container, so that the container can use data from this volume. This is especially important for the import folder, since this is how data can be imported to neo4j.
environment: This is how to configure neo4j on setup. All variables from here will be written to the conf/neo4j.conf file on the docker container. A list of all possible configurations can be found here. Normally, a parameter looks something like this: dbms.connector.bolt.listen_address. However, within docker-compose every . has to be exchanged with a _ and every underscore _ has to be typed as two underscores __.  Also you have to prefix the name with NEO4J_. The example thus becomes NEO4J_dbms_connector_bolt_listen__address. More information on this can be found here. Note that the settings given in the docker-compose file will overwrite any default settings.

Remote connection to neo4j

When using neo4j as the database for a webapp, it will most likely run on a server and require remote access. This does not work by default, there are some settings to be made using the environment section in docker-compose:

NEO4J_dbms_connector_bolt_listen__address=0.0.0.0:7687
NEO4J_dbms_default__listen__address=0.0.0.0
NEO4J_dbms_default__advertised__address=0.0.0.0
NEO4J_dbms_connector_bolt_advertised__address=[Name of server!]

Please do not blindly copy and paste these settings, but do some research on what is needed for your project! However, this is what got ours to work.