The Google Cloud to Neo4j template lets you import a dataset into a Neo4j database through a Dataflow job, sourcing data from CSV files hosted in Cloud Storage buckets. It also lets you manipulate and transform the data at various steps of the import. You can use the template for both first-time imports and incremental imports.
Pipeline requirements
- A running Neo4j instance
- A Cloud Storage bucket
- A dataset to import, in the form of CSV files
- A job specification file to use
Create a job specification file
The job specification file consists of a JSON object with the following sections:
config: global flags affecting how the import is performed.sources: data source definitions (relational).targets: data target definitions (graph: nodes/relationships).actions: pre/post-load actions.
For more information, see Create a job specification file in the Neo4j documentation.
Template parameters
Required parameters
- jobSpecUri: The path to the job specification file, which contains the JSON description of data sources, Neo4j targets and actions.
Optional parameters
- neo4jConnectionUri: The path to the Neo4j connection JSON file.
- neo4jConnectionSecretId: The secret ID for the Neo4j connection metadata. You can use this value as an alternative to the
neo4jConnectionUri. - optionsJson: A JSON object that is also called runtime tokens For example,
{token1:value1,token2:value2}. Spec can refer to $token1 and $token2.. Defaults to empty. - readQuery: SQL query override. Defaults to empty.
- inputFilePattern: The text file path override For example,
gs://your-bucket/path/*.json. Defaults to empty. - disabledAlgorithms: Comma separated algorithms to disable. If this value is set to
none, no algorithm is disabled. Use this parameter with caution, because the algorithms disabled by default might have vulnerabilities or performance issues. For example,SSLv3, RC4. - extraFilesToStage: Comma separated Cloud Storage paths or Secret Manager secrets for files to stage in the worker. These files are saved in the /extra_files directory in each worker. For example,
gs://<BUCKET_NAME>/file.txt,projects/<PROJECT_ID>/secrets/<SECRET_ID>/versions/<VERSION_ID>.
Run the template
Console
- Go to the Dataflow Create job from template page. Go to Create job from template
- In the Job name field, enter a unique job name.
- Optional: For Regional endpoint, select a value from the drop-down menu. The default
region is
us-central1.For a list of regions where you can run a Dataflow job, see Dataflow locations.
- From the Dataflow template drop-down menu, select the Google Cloud to Neo4j template.
- In the provided parameter fields, enter your parameter values.
- Click Run job.
gcloud
In your shell or terminal, run the template:
gcloud dataflow flex-template run JOB_NAME \ --template-file-gcs-location=gs://dataflow-templates-REGION_NAME/VERSION/flex/ \ --project=PROJECT_ID \ --region=REGION_NAME \ --parameters \ jobSpecUri=JOB_SPEC_URI,\ neo4jConnectionUri=NEO4J_CONNECTION_URI,\
Replace the following:
JOB_NAME: a unique job name of your choiceVERSION: the version of the template that you want to useYou can use the following values:
latestto use the latest version of the template, which is available in the non-dated parent folder in the bucket— gs://dataflow-templates-REGION_NAME/latest/- the version name, like
2023-09-12-00_RC00, to use a specific version of the template, which can be found nested in the respective dated parent folder in the bucket— gs://dataflow-templates-REGION_NAME/
REGION_NAME: the region where you want to deploy your Dataflow job—for example,us-central1JOB_SPEC_URI: the path to the job specification fileNEO4J_CONNECTION_URI: the path to the Neo4j connection metadata
API
To run the template using the REST API, send an HTTP POST request. For more information on the
API and its authorization scopes, see
projects.templates.launch.
POST https://dataflow.googleapis.com/v1b3/projects/PROJECT_ID/locations/LOCATION/flexTemplates:launch { "launchParameter": { "jobName": "JOB_NAME", "parameters": { "jobSpecUri": "JOB_SPEC_URI", "neo4jConnectionUri": "NEO4J_CONNECTION_URI", }, "containerSpecGcsPath": "gs://dataflow-templates-LOCATION/VERSION/flex/", "environment": { "maxWorkers": "10" } } }
Replace the following:
PROJECT_ID: the Google Cloud project ID where you want to run the Dataflow jobJOB_NAME: a unique job name of your choiceVERSION: the version of the template that you want to useYou can use the following values:
latestto use the latest version of the template, which is available in the non-dated parent folder in the bucket— gs://dataflow-templates-REGION_NAME/latest/- the version name, like
2023-09-12-00_RC00, to use a specific version of the template, which can be found nested in the respective dated parent folder in the bucket— gs://dataflow-templates-REGION_NAME/
LOCATION: the region where you want to deploy your Dataflow job—for example,us-central1JOB_SPEC_URI: the path to the job specification fileNEO4J_CONNECTION_URI: the path to the Neo4j connection metadata
What's next
- Learn about Dataflow templates.
- See the list of Google-provided templates.