Docker Neo4j

Neo4j 4.x + GraphAware UUID

Starting from Nov 2020, GraphAware has started to support GraphAware framework and UUID for Neo4j 4.x, although rest of the products like recommendation-engine, elasticsearch, expire, resttest, timetree and triggers still support Neo4j 3.x only.

Natively Neo4j supports creation of UUID (v4) through cypher, but they either have to be created during data insert or running bulk inserts via apoc and there isn’t much control of type of UUID’s creation.

Default Neo4j’s UUID creates a “-” in-between the ID’s.

One of the alternate solution is to add GraphAware UUID plugin. GraphAware UUID can create UUID on all nodes (or) specific nodes labels and on relationships as per specification in graphaware.conf file.

For the purpose of the Demo, docker is used to create Neo4j 4.2.2 community version instance. For Neo4j Enterprise, you need to contact GraphAware for License.

(for Non-Docker) Installation is pretty easy. Just add the respective jar versions of GraphAware Framework and GraphAware UUID to the neo4j plugins folder.

Direct Download Link ->

I have created a Dockerfile and docker-compose.yml that will automatically download the plugins and start the database.



FROM neo4j

COPY ./graphaware.conf "${NEO4J_HOME}"/conf
ADD "${NEO4J_HOME}"/plugins
ADD "${NEO4J_HOME}"/plugins


version: '3'

    build: .
    hostname: neo4j_graphaware
    container_name: neo4j_graphaware
      - ./neo4j/data:/var/lib/neo4j/data
      - ./neo4j/import:/var/lib/neo4j/import
      - NEO4J_dbms_default__listen__address=
      - NEO4J_dbms_memory_pagecache_size=1G
      - NEO4J_dbms.memory.heap.initial_size=2G
      - NEO4J_dbms_memory_heap_max__size=4G
      - NEO4J_dbms_directories_import=/var/lib/neo4j/import
      - NEO4J_dbms_security_procedures_unrestricted=gds.*,apoc.*
      - NEO4J_dbms_security_procedures_allowlist=gds.*,apoc.*
      - "7474:7474"
      - "7687:7687"
      - "7473:7473"

The next step is to configure the UUID generation. For the demo purpose, we will generate the UUID for node -> Person, relationship -> REPORTS_TO and UUID without “-” , in the graphaware.conf, which would be later copied into the conf folder by docker.


#UIDM becomes the module ID:

#optional, default is uuid:

#optional, default is false:

#optional, default is all nodes:

#optional, default is no relationships:

Start the neo4j with docker-compose up, and monitor any errors during startup. A successful startup of Neo4j along with GraphAware Framework and UUID should look like below.

Creating network "graphaware_default" with the default driver
Building neo4j
Step 1/5 : FROM neo4j

Step 2/5 : ENV NEO4J_ACCEPT_LICENSE_AGREEMENT=yes     NEO4J_HOME="/var/lib/neo4j"

 ---> a1acb75ca51d
Step 3/5 : COPY ./graphaware.conf "${NEO4J_HOME}"/conf

 ---> 74b7274bd560
Step 4/5 : ADD "${NEO4J_HOME}"/plugins

 ---> 644f9f5eba63
Step 5/5 : ADD "${NEO4J_HOME}"/plugins

 ---> e097a691e2e4

Successfully built e097a691e2e4
Successfully tagged graphaware_neo4j:latest
Creating neo4j_graphaware ... done
Attaching to neo4j_graphaware
neo4j_graphaware | Directories in use:
neo4j_graphaware |   home:         /var/lib/neo4j
neo4j_graphaware |   config:       /var/lib/neo4j/conf
neo4j_graphaware |   logs:         /logs
neo4j_graphaware |   plugins:      /var/lib/neo4j/plugins
neo4j_graphaware |   import:       /var/lib/neo4j/import
neo4j_graphaware |   data:         /var/lib/neo4j/data
neo4j_graphaware |   certificates: /var/lib/neo4j/certificates
neo4j_graphaware |   run:          /var/lib/neo4j/run
neo4j_graphaware | Starting Neo4j.
neo4j_graphaware | 2021-01-13 00:14:04.193+0000 WARN  Unrecognized setting. No declared setting with name: metrics.enabled
neo4j_graphaware | 2021-01-13 00:14:04.207+0000 INFO  Starting...
neo4j_graphaware | 2021-01-13 00:14:05.807+0000 INFO  ======== Neo4j 4.2.2 ========
neo4j_graphaware | 2021-01-13 00:14:07.095+0000 INFO  GraphAware Runtime disabled for database system.
neo4j_graphaware | 2021-01-13 00:14:08.931+0000 INFO  Performing postInitialization step for component 'security-users' with version 2 and status CURRENT
neo4j_graphaware | 2021-01-13 00:14:08.931+0000 INFO  Updating the initial password in component 'security-users'
neo4j_graphaware | 2021-01-13 00:14:09.516+0000 INFO  GraphAware Runtime enabled for database neo4j, bootstrapping...
neo4j_graphaware | 2021-01-13 00:14:09.528+0000 INFO  Bootstrapping module with order 1, ID UIDM, using com.graphaware.module.uuid.UuidBootstrapper for database neo4j
neo4j_graphaware | 2021-01-13 00:14:09.531+0000 INFO  Node Inclusion Policy set to com.graphaware.common.policy.inclusion.composite.CompositeNodeInclusionPolicy@21e78ee8       
neo4j_graphaware | 2021-01-13 00:14:09.533+0000 INFO  Relationship Inclusion Policy set to com.graphaware.common.policy.inclusion.composite.CompositeRelationshipInclusionPolicy@658e6daa@658e6daa
neo4j_graphaware | 2021-01-13 00:14:09.534+0000 INFO  uuidProperty set to uuid
neo4j_graphaware | 2021-01-13 00:14:09.534+0000 INFO  stripHyphens set to true
neo4j_graphaware | 2021-01-13 00:14:09.535+0000 INFO  Registering module UIDM with GraphAware Runtime for database neo4j.
neo4j_graphaware | 2021-01-13 00:14:09.536+0000 INFO  GraphAware Runtime bootstrapped for database neo4j.
neo4j_graphaware | 2021-01-13 00:14:09.578+0000 INFO  Starting GraphAware Runtime for database neo4j...
neo4j_graphaware | 2021-01-13 00:14:09.578+0000 INFO  Starting GraphAware Runtime modules for database neo4j...
neo4j_graphaware | 2021-01-13 00:14:09.579+0000 INFO  Starting module UIDM for database neo4j...
neo4j_graphaware | 2021-01-13 00:14:09.584+0000 INFO  Started module UIDM for database neo4j.
neo4j_graphaware | 2021-01-13 00:14:09.586+0000 INFO  GraphAware Runtime modules started for database neo4j.
neo4j_graphaware | 2021-01-13 00:14:09.586+0000 INFO  Started GraphAware Runtime for database neo4j.
neo4j_graphaware | 2021-01-13 00:14:09.668+0000 INFO  Bolt enabled on
neo4j_graphaware | 2021-01-13 00:14:10.518+0000 INFO  Remote interface available at http://localhost:7474/
neo4j_graphaware | 2021-01-13 00:14:10.519+0000 INFO  Started.                                                                                                                  

Node UUID Generation Testing

1. Create a sample data with label Person, to verify if UUID is created.

MERGE (n:Person {name: "Dominic"}) RETURN n;
│"n"               │

match (n:Person) return labels(n),n
│"labels(n)"│"n"                                                         │
│["Person"] │{"name":"Dominic","uuid":"9a77dfec7b95484eb9f22c848b0ad8f5"}│

MERGE (n:Person {name: "Kumar"}) RETURN n;
│"n"             │

match (n:Person) return labels(n),n;
│"labels(n)"│"n"                                                         │
│["Person"] │{"name":"Kumar","uuid":"5f36188e4079406d9c202c4e0feaf785"}  │
│["Person"] │{"name":"Dominic","uuid":"9a77dfec7b95484eb9f22c848b0ad8f5"}│

the above output shows that UUID is created for label Person automatically as specified in the graphaware configuration file.

2. We will test if UUID is created for any other labels, not specified in the graphaware configuration file.

merge (s:State{name:"Texas"}) return s
│"s"             │

match (n:State) return labels(n),n
│"labels(n)"│"n"             │
│["State"]  │{"name":"Texas"}│

from the above output, it clearly shows that UUID is not created for Label-> State, because, it was not specified in the graphaware configuration file.

Relationship UUID Generation Testing

To test the automatic UUID generation for relationship, we will create two types of relationships – (1) RESIDES_IN and (2) REPORTS_TO, the former is Not specified in the graphaware.conf configuration file, whereas the latter is.

match (p:Person{name:"Dominic"}), (s:State{name:"Texas"}) merge (p)-[:RESIDES_IN]->(s)

Created 1 relationship, completed after 33 ms.

match (p1:Person{name:"Dominic"}), (p2:Person{name:"Kumar"}) merge (p1)-[:REPORTS_TO]->(p2)

Created 1 relationship, completed after 8 ms.

match (m)-[r]->(n)   return labels(m) as labels_1 , ,type(r) as rel_label ,r as rel ,labels(n) as labels_2 ,

│"labels_1"│"" │"rel_label" │"rel"                                      │"labels_2"│""│
│["Person"]│"Dominic"│"RESIDES_IN"│{}                                         │["State"] │"Texas" │
│["Person"]│"Dominic"│"REPORTS_TO"│{"uuid":"2596a1bf5bd14a148571550ce275d743"}│["Person"]│"Kumar" │

As you can see, UUID is automatically created for relationship REPORTS_TO only.

Happy Graphing …..

 424 total views,  2 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.