Memgraph

Description

Memgraph is an in-memory graph database for realtime and scalable analytics which speaks Cypher over the Bolt protocol. Hop connects to it with a graph database connection of the Memgraph type. See Graph databases for the other graph databases Hop works with.

Run Memgraph in docker

Example command to start a Memgraph server in a container:

docker run -it -p 7687:7687 memgraph/memgraph

Memgraph Lab, the browser of Memgraph, runs in a container of its own: docker run -p 3000:3000 memgraph/lab.

What works

Use a graph database connection of the Memgraph type. With it, these work:

What doesn’t work

  • Neo4j import: it runs neo4j-admin. Load the files of Generate graph CSVs with plain column names and LOAD CSV instead.

  • Named indexes and constraints: Memgraph identifies them by their label and properties. The Graph index and Graph constraint actions ignore the names you give them, and drop them by label and properties.

  • Node key constraints (a combination of properties which has to exist and be unique, a Neo4j Enterprise feature) and constraints on relationships: Memgraph doesn’t have them. The Graph constraint action only offers unique and existence constraints on nodes.

  • Edge indexes on more than one property, and existence constraints on more than one property.

Memgraph syntax

The Memgraph connection type makes Hop generate Memgraph’s syntax, like a SQL dialect does for relational databases:

Operation Statement

Graph index: node index

CREATE INDEX ON :Person(id), with several properties CREATE INDEX ON :Person(a, b)

Graph index: relationship index

CREATE EDGE INDEX ON :KNOWS(since)

Graph index: drop

DROP INDEX ON :Person(id), DROP EDGE INDEX ON :KNOWS(since)

Graph constraint: unique

CREATE CONSTRAINT ON (n:Person) ASSERT n.id IS UNIQUE

Graph constraint: existence

CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.name)

Graph constraint: drop

DROP CONSTRAINT ON (n:Person) ASSERT n.id IS UNIQUE

Graph output and Cypher output with Create indexes

A unique constraint for a single key property, an index for several

Memgraph doesn’t run some statements in an explicit transaction: information queries like SHOW INDEX INFO, and index and constraint changes. Hop runs them on their own, in auto-commit transactions: in the Graph index and Graph constraint actions, in the Graph script action, and in the Graph query transform when every statement of a batch is one of them.

Known issues

With a Neo4j connection (protocol bolt) instead of a Memgraph connection, Hop uses the Neo4j syntax and transactions: creating indexes and constraints fails, for example with Index manipulation not allowed in multicommand transactions.. Change the type of the connection to Memgraph to solve this: convert the Neo4j connection to a graph database connection and select the Memgraph type.

Check the Memgraph docs for more information on indexing.