> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Run the Neo4j Connector Externally

> Use YAML to configure Neo4j database connections with metadata ingestion.

![Neo4j](https://docs.open-metadata.org/public/images/connectors/neo4j.svg)

# Neo4j

BETA

This section provides guides and references for the Neo4j connector.
Configure Neo4j metadata workflows externally with YAML:

* [Requirements](#requirements)
* [Metadata Ingestion](#metadata-ingestion)

## How to Run the Connector Externally

To run the Ingestion via the UI you'll need to use the OpenMetadata Ingestion Container, which comes shipped with
custom Airflow plugins to handle the workflow deployment.

If, instead, you want to manage your workflows externally on your preferred orchestrator, you can check
the following docs to run the Ingestion Framework **anywhere**.

> **[External Schedulers](https://docs.open-metadata.org/v2.1.x-SNAPSHOT/deployment/ingestion.md)**
>
> Get more information about running the Ingestion Framework Externally

## Requirements

OpenMetadata reads the graph schema of one Neo4j database. It reads schema information only and never reads node or relationship data. The connecting user needs the `ACCESS` privilege on the database and permission to execute the following procedures:

* `db.info`
* `db.labels`
* `db.relationshipTypes`
* `db.schema.nodeTypeProperties`
* `db.schema.relTypeProperties`

The built-in `reader` role is enough.

### Entity Mapping

OpenMetadata maps the Neo4j graph schema to OpenMetadata entities as follows:

| Neo4j | OpenMetadata Entity | Description |
| - | - | - |
| **Database** | **Database** | The Neo4j database that the connection reads. Each ingestion run reads one database. |
| **Node labels** | **Tables** in the `nodes` schema | One table for each node label. A node with several labels contributes to the table of each label. |
| **Relationship types** | **Tables** in the `relationships` schema | One table for each relationship type. OpenMetadata creates these tables only when **Include Relationships** is on. |
| **Properties** | **Columns** | The properties of a node label or relationship type become the columns of its table. |

A property is `NOT NULL` only when every node type with that label has the property and marks it as mandatory. When a property has more than one type, or a type that OpenMetadata doesn't recognize, OpenMetadata sets the column to the `UNKNOWN` data type and ingestion continues.

### Python Requirements

Use Python 3.10 or later. Python 3.12 is recommended, because it is what the OpenMetadata 2.0 ingestion images use. To confirm the supported range for your release, check the `Requires-Python` metadata of that release’s `openmetadata-ingestion` package.

To run the Neo4j ingestion, install:

```bash theme={null}
pip3 install "openmetadata-ingestion[neo4j]"
```

## Metadata Ingestion

All connectors are defined as JSON Schemas.
See the [Neo4j connection JSON Schema](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/neo4jConnection.json) for the full set of properties.
To create and run a metadata ingestion workflow, create a YAML configuration. The configuration connects to the source, processes entities if needed, and reaches the OpenMetadata server.
The workflow is modeled around the following
[JSON Schema](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/workflow.json).

### 1. Define the YAML Config

Use the following YAML configuration as a starting point.

#### Source Configuration

Configure the source type and service name for your Neo4j connector.

#### Connection Scheme

**scheme**: The Neo4j driver URI scheme. Defaults to `neo4j`. Choose one of `neo4j`, `neo4j+s`, `neo4j+ssc`, `bolt`, `bolt+s`, or `bolt+ssc`. Use `neo4j+s` for Neo4j Aura.

#### Host Port

**hostPort**: The host and port of the Neo4j server, for example `localhost:7687`. If you omit the port, OpenMetadata uses 7687.

#### Username and Password

**username**: The username to connect to Neo4j. The user needs read access to the graph schema of the database.

**password**: The password to connect to Neo4j.

#### Database and Filters

**databaseName**: The Neo4j database to extract metadata from. When omitted, OpenMetadata uses the home database of the user.

**includeRelationships**: On by default. When on, OpenMetadata also ingests relationship types as tables in the `relationships` schema.

**propertyFilterPattern**: A regex that includes or excludes the node and relationship properties (columns) that match the pattern.

#### Source Config

The `sourceConfig` is defined [here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/databaseServiceMetadataPipeline.json):

* **markDeletedTables**: To flag tables as soft-deleted if they are not present anymore in the source system.
* **markDeletedStoredProcedures**: Optional configuration to soft delete stored procedures in OpenMetadata if the source stored procedures are deleted. Also, if the stored procedure is deleted, all the associated entities like lineage, etc., with that stored procedure will be deleted.
* **markDeletedSchemas**: Optional configuration to soft delete schemas stored in OpenMetadata if the source schema is deleted. Setting this flag to true will only keep filtered schemas and delete any other schemas that do not match schemaFilterPattern or do not exist at source.
* **markDeletedDatabases**: Additional optional configuration for soft deletion, providing a granular option to select which particular entities should be deleted.
* **includeTables**: Set to `true` or `false` to ingest table data. Default is `true`.
* **includeViews**: Set to `true` or `false` to ingest view definitions.
* **includeTags**: Optional configuration to toggle the tags ingestion.
* **includeOwners**: Set the **Include Owners** toggle to control whether to include owners to the ingested entity if the owner email matches with a user stored in the OM server as part of metadata ingestion. If the ingested entity already exists and has an owner, the owner will not be overwritten.
* **ownerConfig**: Advanced, hierarchical configuration for assigning owners to databases, schemas, and tables during ingestion, with per-entity mappings and inheritance. For more information, see [Hierarchical Owner Configuration](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/hierarchical-owner-configuration.md).
* **includeStoredProcedures**: Optional configuration to toggle the Stored Procedures ingestion.
* **includeDDL**: Optional configuration to toggle the DDL Statements ingestion.
* **overrideMetadata** *(boolean)*: Set the **Override Metadata** toggle to control whether to override the existing metadata in the OpenMetadata server with the metadata fetched from the source. If the toggle is set to true, the metadata fetched from the source will override the existing metadata in the OpenMetadata server. If the toggle is set to false, the metadata fetched from the source will not override the existing metadata in the OpenMetadata server. This is applicable for fields like description, tags, owner, and displayName.
* **queryLogDuration**: Configuration to tune how far we want to look back in query logs to process Stored Procedures results.
* **queryParsingTimeoutLimit**: Configuration to set the timeout for parsing the query in seconds.
* **useFqnForFiltering**: Regex will be applied on the fully qualified name (for example, `service_name.db_name.schema_name.table_name`) instead of the raw name (for example, `table_name`).
* **databaseFilterPattern**, **schemaFilterPattern**: Note that the filter supports regex as include or exclude. You can find examples [here](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/filter-patterns/database.md).
* **tableFilterPattern**: Note that the filter supports regex as include or exclude. You can find examples [here](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/filter-patterns/table.md).
* **threads (beta)**: The number of threads to use when extracting the metadata using multithreading.
* **databaseMetadataConfigType** *(string)*: Database Source Config Metadata Pipeline type.
* **incremental (beta)**: Incremental Extraction configuration. Currently implemented for [BigQuery](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/incremental-extraction/bigquery.md), [Redshift](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/incremental-extraction/redshift.md), and [Snowflake](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/incremental-extraction/snowflake.md).

#### Sink Configuration

To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.

#### Workflow Configuration

The main property here is `openMetadataServerConfig`, where you can define the host and security provider of your OpenMetadata installation.

* **loggerLevel**: Specify the logger level depending on your needs. If you are troubleshooting an ingestion, use `DEBUG` for more detailed traces.
* **JWT token**: JWT tokens allow clients to authenticate against the OpenMetadata server. See [Enable JWT Tokens](https://docs.open-metadata.org/deployment/security/enable-jwt-tokens.md) and [JWT Troubleshooting](https://docs.open-metadata.org/deployment/security/jwt-troubleshooting.md) for more information.
* **storeServiceConnection**: If set to `true` (default), sensitive information is stored encrypted with the Fernet Key or externally if you have configured a [Secrets Manager](https://docs.open-metadata.org/deployment/secrets-manager.md). If set to `false`, the service is created, but the service connection information is only used by the Ingestion Framework at runtime and is not sent to the OpenMetadata server.
* **SSL configuration**: If you have added SSL to the [OpenMetadata server](https://docs.open-metadata.org/deployment/security/enable-ssl.md), configure the certificates for ingestion. Set `verifySSL` to `ignore`, or set it to `validate` and provide `sslConfig.caCertificate` with a local path to the server certificate. See [SSL Troubleshooting](https://docs.open-metadata.org/deployment/security/enable-ssl/ssl-troubleshooting.md) for more information.
* **ingestionPipelineFQN**: Fully qualified name of the ingestion pipeline, used to identify the current ingestion pipeline.

neo4j\_config.yaml
Copy full code

```yaml theme={null}
source:
  type: neo4j
  serviceName: local_neo4j
  serviceConnection:
    config:
      type: Neo4j
      scheme: neo4j
      hostPort: localhost:7687
      username: <username>  # REQUIRED
      password: <password>  # REQUIRED
      # databaseName: neo4j  # defaults to the home database of the user
      # includeRelationships: true
      # propertyFilterPattern:
      #   excludes:
      #     - "louvain.*"
```

```yaml theme={null}
  sourceConfig:
    config:
      type: DatabaseMetadata
      markDeletedTables: true
      markDeletedStoredProcedures: true
      markDeletedSchemas: true
      markDeletedDatabases: true
      includeTables: true
      includeViews: true
      # includeTags: true
      # includeOwners: false
      # ownerConfig:
      #   default: data-platform-team
      #   database:
      #     database1: owner1
      #   databaseSchema:
      #     database1.schema1: owner1
      #   table:
      #     database1.schema1.table1: owner1
      #   enableInheritance: true
      # includeStoredProcedures: true
      # includeDDL: true
      # overrideMetadata: false
      # queryLogDuration: 1
      # queryParsingTimeoutLimit: 300
      # useFqnForFiltering: false
      # threads: 1
      # databaseMetadataConfigType: ()
      # incremental:
      #   enabled: true
      #   lookbackDays: 7
      #   safetyMarginDays: 1
      # databaseFilterPattern:
      #   includes:
      #     - database1
      #     - database2
      #   excludes:
      #     - database3
      #     - database4
      # schemaFilterPattern:
      #   includes:
      #     - schema1
      #     - schema2
      #   excludes:
      #     - schema3
      #     - schema4
      # tableFilterPattern:
      #   includes:
      #     - users
      #     - type_test
      #   excludes:
      #     - table3
      #     - table4
```

```yaml theme={null}
sink:
  type: metadata-rest
  config: {}
```

```yaml theme={null}
workflowConfig:
  loggerLevel: INFO  # DEBUG, INFO, WARNING or ERROR
  openMetadataServerConfig:
    hostPort: "http://localhost:8585/api"
    authProvider: openmetadata
    securityConfig:
      jwtToken: "{bot_jwt_token}"
    ## Store the service Connection information
    storeServiceConnection: true  # false
    ## Secrets Manager Configuration
    # secretsManagerProvider: aws, azure or noop
    # secretsManagerLoader: airflow or env
    ## If SSL, fill the following
    # verifySSL: validate  # or ignore
    # sslConfig:
    #   caCertificate: /local/path/to/certificate
# ingestionPipelineFQN: <service name>.<ingestion name> ## e.g., "my_redshift.metadata"
```

### 2. Run with the CLI

First, we will need to save the YAML file. Afterward, and with all requirements installed, we can run:

```bash theme={null}
metadata ingest -c <path-to-yaml>
```

Note that from connector to connector, this recipe will always be the same. By updating the YAML configuration,
you will be able to extract metadata from different sources.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.