Export to a new Neo4j database

This feature is not available in AuraDS.
This feature is not available in GDS Sessions.

We can create new Neo4j databases from projected graphs stored in the graph catalog. All nodes, relationships and properties present in the projected graph are written to a new Neo4j database. This includes data that has been projected in gds.graph.project and data that has been added by running algorithms in mutate mode. The newly created database will be stored in the Neo4j databases directory using a given database name.

The feature is useful in the following, exemplary scenarios:

  • Avoid heavy write load on the operational system by exporting the data instead of writing back.

  • Create an analytical view of the operational system that can be used as a basis for running algorithms.

  • Produce snapshots of analytical results and persistent them for archiving and inspection.

  • Share analytical results within the organization.

Syntax

Export a projected graph to a new database in the Neo4j databases directory:
CALL gds.graph.export(graphName: String, configuration: Map)
YIELD
    dbName: String,
    graphName: String,
    nodeCount: Integer,
    nodePropertyCount: Integer,
    relationshipCount: Integer,
    relationshipTypeCount: Integer,
    relationshipPropertyCount: Integer,
    writeMillis: Integer
Table 1. Parameters
Name Type Optional Description

graphName

String

no

The name under which the graph is stored in the catalog.

configuration

Map

no

Additional parameters to configure the database export.

Table 2. Graph export configuration
Name Type Default Optional Description

dbName

String

none

No

The name of the exported Neo4j database.

dbFormat

String

db_format default value

yes

Database format. Valid values are blank (no value, default), standard, aligned, high_limit or block.

writeConcurrency

Boolean

4

yes

The number of concurrent threads used for writing the database.

enableDebugLog

Boolean

false

yes

Prints debug information to Neo4j log files (deprecated).

batchSize

Integer

10000

yes

Number of entities processed by one single thread at a time.

defaultRelationshipType

String

__ALL__

yes

Relationship type used for * relationship projections.

additionalNodeProperties

String, List or Map

{}

yes

Allows for exporting additional node properties from the original graph backing the in-memory graph.

Table 3. Results
Name Type Description

dbName

String

The name of the exported Neo4j database.

graphName

String

The name under which the graph is stored in the catalog.

nodeCount

Integer

The number of nodes exported.

nodePropertyCount

Integer

The number of node properties exported.

relationshipCount

Integer

The number of relationships exported.

relationshipTypeCount

Integer

The number of relationship types exported.

relationshipPropertyCount

Integer

The number of relationship properties exported.

writeMillis

Integer

Milliseconds for writing the graph into the new database.

Example

Export the my-graph from GDS into a Neo4j database called mydatabase:
CALL gds.graph.export('my-graph', { dbName: 'mydatabase' })

The new database can be started using databases management commands.

The database must not exist when using the export procedure. It needs to be created manually using the following commands.

After running exporting the graph, we can start a new database and query the exported graph:
:use system
CREATE DATABASE mydatabase;
:use mydatabase
MATCH (n) RETURN n;

Example with additional node properties

Suppose we have a graph my-db-graph in the Neo4j database that has a string node property myproperty, and that we have a corresponding in-memory graph called my-in-memory-graph which does not have the myproperty node property. If we want to export my-in-memory-graph but additionally add the myproperty properties from my-db-graph we can use the additionalProperties configuration parameter.

Export the my-in-memory-graph from GDS with myproperty from my-db-graph into a Neo4j database called mydatabase:
CALL gds.graph.export('my-graph', { dbName: 'mydatabase', additionalNodeProperties: ['myproperty']})

The new database can be started using databases management commands.

The original database (my-db-graph) must not have changed since loading the in-memory representation (my-in-memory-graph) that we export in order for the export to work correctly.

The additionalNodeProperties parameter uses the same syntax as nodeProperties of the graph project procedure. So we could for instance define a default value for our myproperty.

Export the my-in-memory-graph from GDS with myproperty from my-db-graph with default value into a Neo4j database called mydatabase:
CALL gds.graph.export('my-graph', { dbName: 'mydatabase', additionalNodeProperties: [{ myproperty: {defaultValue: 'my-default-value'}}] })