Search docs.molo17.com

    Neo4j logo Neo4j agent

    Target Neo4j

    The Neo4j target agent (agent tag neo4j) writes nodes and relationships with batched MERGE statements. It works on every edition of Neo4j, Community and Aura included, and every write is idempotent.

    Prerequisites

    To have Gluesync working on your Neo4j instance as a target you will need:

    • Neo4j 5.13 to 5.26 LTS, or a 2025.x or 2026.x calendar release, on any edition;

    • A user that can read and write the graph, for the labels and relationship types you replicate;

    • A user that can create constraints and list them, unless you turn off Create constraints and create them yourself: the agent creates the constraints that a MERGE needs, see Constraints. The script in Create the Gluesync user creates a user that can do all of it, as a source and as a target;

    • A key on every entity, which identifies a node or a relationship;

    • Network access from Core Hub to the Bolt port of the server (default 7687).

    Setup via Web UI

    • Hostname / IP Address: DNS record or IP Address of the Neo4j server. It can be left empty when you set the connection URI;

    • Port: Optional, defaults to 7687;

    • Database name: The database the agent writes to. Defaults to neo4j;

    • Username: Username with read and write access to the target;

    • Password: Password belonging to the given username;

    • Connection URI (replaces host, port and TLS): (optional) The complete URI of the server, such as neo4j+s://<id>.databases.neo4j.io for Aura. When it is set, the host, the port, the TLS settings and the URI scheme are ignored;

    • Enable TLS: Optional, defaults to false. Encrypts the connection and verifies the certificate of the server (+s);

    • Trust server certificate: Optional, defaults to false. With Enable TLS, encrypts the connection without verifying the certificate (+ssc);

    • CA certificate path (PEM): (optional) A PEM file with the certificate authority of the server. When it is set, the connection is encrypted and verified against it;

    • Disable auth: Optional, defaults to false. Connects without credentials;

    • Max connections count: Size of the connection pool of the driver. Defaults to 25.

    The rules for the connection URI, the TLS settings and the timeouts are the same as for the source, and are described in Setup via Web UI of the source.

    Custom properties

    This can be also set via Rest API by specifying the customHostCredentials param.

    • URI scheme: (optional, defaults to neo4j) neo4j routes to the members of a cluster, which a cluster and Aura need. bolt connects directly to the server you name. Ignored when a connection URI is set;

    • Bearer token: (optional) A bearer token, used instead of the username and password.

    Specific configuration

    This agent has no specific configuration properties for the target role.

    Entity settings

    Each entity has settings of its own that say what it writes. A node entity needs none of them: it writes the label of its name. A relationship entity needs at least Entity kind, the two labels and the keys of the end nodes.

    Setting Default Description

    Entity kind (entityKind)

    NODE

    NODE or RELATIONSHIP. Set RELATIONSHIP on an entity that writes relationships: the name of the entity does not decide it on a target.

    Node label (nodeLabel)

    empty

    The label the nodes are written with. When it is empty, the name of the entity is used.

    Additional labels (additionalLabels)

    empty

    Comma-separated labels that a node is also given, next to its main label. A node is found by its main label and its key, and the agent adds the other labels, never removes them.

    Relationship type (relationshipType)

    empty

    Relationship entities only. The type the relationships are written with. When it is empty, the name of the entity is used, and an entity named [:KNOWS] writes the type KNOWS.

    Start node label (startLabel)

    empty

    Relationship entities only, required. The label of the start node of the relationship.

    End node label (endLabel)

    empty

    Relationship entities only, required. The label of the end node.

    Start node key mapping (startKeyMapping)

    empty

    Relationship entities only. Comma-separated sourceColumn:nodeProperty pairs, one for each key property of the start node. A pair without a colon maps a column to the property of the same name. When it is empty, the columns named start<property> are used, each for the property <property>.

    End node key mapping (endKeyMapping)

    empty

    Relationship entities only. The same for the end node, with the columns named end<property> when it is empty.

    Create missing endpoint nodes (createMissingEndpoints)

    true

    Relationship entities only. Creates the start or end node of a relationship when it is not in the database yet, as a node that has only its key properties. See Writing relationships.

    Create constraints (createConstraints)

    true

    On the first write of the entity, creates the constraints that a MERGE needs: node keys on Enterprise Edition, uniqueness constraints on Community. An equivalent constraint that exists is left as it is. See Constraints.

    Write batch size (writeBatchSize)

    1000

    Rows in one write transaction.

    Bulk batch size (bulkBatchSize)

    500

    Rows in one write transaction on the bulk path. See Bulk operations.

    Write parallelism (writeParallelism)

    4

    Write transactions that run at the same time for one batch of changes. It applies to nodes only and only when the label has a constraint: a relationship entity always writes with one, and so does an entity without a constraint.

    The entity keys are the key columns of the entity. As on every NoSQL agent, you can mark other columns as the key. The key columns that the start and end key mappings use identify the end nodes, and are not written as properties of the relationship.

    Writing to Neo4j

    Gluesync writes every batch of changes with UNWIND $rows AS row …​ statements. Labels, types and property names are escaped, and values travel as parameters.

    A node is written with a MERGE on its main label and its key, then its properties are set:

    UNWIND $rows AS row
    MERGE (n:`Person` {`id`: row.k.`id`})
    SET n += row.p

    If the entity has additional labels, they are set in the same SET. A delete removes the node and the relationships attached to it:

    UNWIND $rows AS row
    MATCH (n:`Person` {`id`: row.k.`id`})
    DETACH DELETE n

    What follows from these statements:

    • Inserts and updates are the same write. MERGE finds the node by its key and creates it only when it is not there. An insert onto a key that already exists updates the node, and a batch that Core Hub replays ends in the same graph. An insert never fails on an existing key, so the On duplicate key setting does not apply to this target and is not shown;

    • A NULL removes the property. SET n += row.p with a NULL value removes that property from the node. A property that the entity does not have as a column is left as it is, whoever wrote it;

    • A relationship with its own key can change its endpoints. The agent finds the relationship by its key. When the start or end node of the row is not the one it connects, Neo4j cannot re-point a relationship, so the agent deletes it and creates it again between the new nodes, in the same transaction, keeping the properties the row does not carry. A relationship without its own key is identified by its two nodes, so an update that changes them writes a new relationship;

    • The key cannot be NULL. A change whose key column is missing or NULL is refused with an error that names the entity and the column, instead of being written under an empty key;

    • The last change of a key wins inside a batch. Before it writes, the agent compacts the rows of a batch by key, taking the changes of a key in order: consecutive upserts become one that sets what the later ones carry and leaves the rest; an upsert followed by a delete is only the delete, and so is an insert followed by a delete, which is kept as a delete and not dropped because a replay may have left the node in the database already; a delete followed by an upsert is both, in that order, so the node is removed and written again and what it had before is gone. Deletes run first, then the upserts, in chunks of Write batch size rows;

    • Chunks run in parallel without clashing. The chunks are spread over Write parallelism workers by the hash of the key, so a key is never in two concurrent transactions.

    Every transaction goes through the driver, which retries it on a transient error, such as a deadlock. That is safe because every statement is idempotent.

    Truncate

    When the Core Hub option to truncate the target before a snapshot is on, the agent deletes every node that carries the label (DETACH DELETE, with its relationships), or every relationship of the type, in batches of 10000, each in its own transaction, until none is left. Only the nodes of that label are removed: the label is not dropped, and neither are constraints.

    Writing relationships

    A relationship entity writes one type of relationship between two labels. Its columns are the properties of the relationship, and the columns that carry the keys of the two end nodes, by default start<property> and end<property> as a Neo4j source produces them. For another source, point the key mappings at the columns that hold the keys, for example a table of orders that links customers to products:

    Entity kind:                 RELATIONSHIP
    Relationship type:           BOUGHT
    Start node label:            Customer
    End node label:              Product
    Start node key mapping:      customer_id:id
    End node key mapping:        product_sku:sku

    Each row is written with:

    UNWIND $rows AS row
    MERGE (a:`Customer` {`id`: row.s.`id`})
    MERGE (b:`Product` {`sku`: row.e.`sku`})
    MERGE (a)-[r:`BOUGHT`]->(b)
    SET r += row.p

    If the relationship has a key of its own, the relationship pattern carries it:

    MERGE (a)-[r:`BOUGHT` {`orderId`: row.k.`orderId`}]->(b)

    A delete of such a relationship finds it by that key alone and needs no end node. Without a key, a delete finds it by its type and its two end nodes.

    • End node stubs. With Create missing endpoint nodes on, the end nodes are MERGE`d too: a node that is not in the database yet is created with its key properties only, and a pipeline of the nodes that comes later fills in the other properties through its own `MERGE. The order of the pipelines of nodes and relationships does not matter. The stub carries the label you name, and no additional label;

    • No stubs. With Create missing endpoint nodes off, the end nodes are `MATCH`ed. A row whose start or end node is not in the database is skipped. The agent counts the skipped rows of each write, and once the write is done it logs one warning that names the entity, the number of rows not written and up to five sample end nodes that are missing, for example start Person {id=99}. The warning says to write the node entities first or to turn the setting on. The samples come from a lookup that runs only when rows were skipped, and if it fails the write still succeeds and the warning says that no sample could be read;

    • Parallel relationships collapse without a key. A relationship with no key is identified by its start node, its type and its end node, so two relationships of the same type between the same two nodes become one. If the data has such pairs, give the relationships a key property, and a key column on the entity. A delete of a relationship without a key removes every relationship of that type between the two nodes;

    • One transaction at a time. Relationships are written with one transaction at a time, because they share their end nodes with each other.

    The agent checks a relationship entity before it writes: it needs both labels, a key mapping (or start* and end* columns) for both ends, and the mapped columns have to exist in the entity. The failure lists each problem.

    Constraints

    A MERGE finds a node by its label and key. Without a uniqueness constraint on that key, Neo4j scans the label for every row, and two writers that merge the same new key at the same moment create two nodes. So on the first write of an entity, the agent looks up the constraints and creates the ones that are missing, when Create constraints is on:

    • A node entity: on Enterprise Edition (Aura included) a NODE KEY constraint on the key properties of the label, named like gs_nodekey_Person_id; on Community Edition a uniqueness constraint, named like gs_node_Person_id, because Community has no node keys. A key of several columns gives a composite constraint;

    • A relationship entity: the same constraint on the key properties of the start label and of the end label, so the stub nodes that a relationship pipeline merges carry a node key too, and, when the relationship has a key of its own, a RELATIONSHIP KEY constraint on Enterprise Edition and a uniqueness constraint on the other editions.

    Every statement is CREATE CONSTRAINT …​ IF NOT EXISTS. The agent reads the existing constraints first. A constraint that already covers the same properties is taken as it is, whatever its name and its kind, and nothing is created or dropped. In particular an existing uniqueness constraint covers the key for writing: Neo4j refuses a node key next to it, and the agent never drops a constraint or replaces it with a node key. The result is remembered for the entity until a truncate.

    A node key makes a Neo4j Enterprise target usable as a change data capture source of relationships: the change log lists the key properties of a node only for a label that has a node key. If a downstream pipeline reads relationships from this database and the label has a uniqueness constraint that you created yourself, replace it as described in Key constraints.

    Neo4j refuses a node key when existing nodes of the label lack one of the key properties, while a uniqueness constraint ignores such nodes. The agent then creates the uniqueness constraint instead and logs a warning with the reason the server gave, so a label that worked before keeps working. A node key that cannot be created as a uniqueness constraint either is reported like any other constraint that cannot be created, below.

    When you create the target entity with the Create table option of Core Hub, the same statements run. For a relationship entity only the constraint on its own key is created at that point, and the constraints on the end labels are created on the first write. See Target table creation.

    If a constraint cannot be created, because the user has no privilege or because the data already holds duplicates of the key, or if Create constraints is off, the agent logs a warning that names the label, the properties and the Cypher to run. It then writes with no risk of duplicates but slower:

    • one transaction at a time for the entity, whatever Write parallelism says, and no CREATE on the bulk path;

    • one writer at a time for all the entities of the agent that touch the same labels or relationship type, because two entities, or a pipeline of nodes and a pipeline of relationships that creates the same end nodes, can write at once. A relationship entity is serialized unless its end keys and its own key are all covered by constraints, so a relationship without a key of its own always is.

    Create the constraints on the database before the first write when you turn Create constraints off, or when the user cannot create them.

    Bulk operations

    Two flags of the entity turn the bulk path on, and each is independent of the other:

    • Use bulk operations while snapshot (useBulkOperationsWhileSnapshot, defaults to false);

    • Use bulk operations during CDC (useBulkOperationsDuringCDC, defaults to false).

    See Write strategies for how to set them. The bulk path writes in transactions of Bulk batch size rows (default 500), with the same spread over Write parallelism workers. No staging table is created.

    • Snapshot. When the first bulk object of a snapshot arrives, the agent checks whether the label (or the relationship type) has any node (or relationship) in it, and remembers the answer for the snapshot. If it is empty, the rows are written with CREATE, which skips the matching half of a MERGE:

      UNWIND $rows AS row
      CREATE (n:`Person`)
      SET n = row.p

      For relationships, the end nodes are found or merged as for the batch path, and the relationship is created between them. If the label already holds nodes, the rows are MERGE`d, in chunks of Bulk batch size. A relationship entity without a key is never created in bulk, because a `CREATE would keep two parallel relationships that a MERGE collapses. The deletes that a snapshot carries are skipped;

    • Restart of a snapshot. CREATE needs a constraint on the key, a node key or a uniqueness constraint: with it a duplicate fails the transaction, and the agent writes that chunk, and every chunk after it, with MERGE. A snapshot that restarts and replays rows converges to the same graph;

    • CDC. The rows of one transaction are compacted as in Writing to Neo4j, then deleted and MERGE`d in chunks of Bulk batch size. An update is a `MERGE, never a delete followed by an insert, so the relationships attached to a node stay in place. A truncate in the stream runs in its place.

    The bulk path never writes with CREATE when the entity has no constraint, as described in Constraints.

    Data types

    Neo4j has no decimal type and no map property, and a property that has no value does not exist. The agent writes a Gluesync type as the default Neo4j type below, or as one of the supported types you choose for the column.

    Gluesync type Default Neo4j type Supported types Notes

    STRING

    STRING

    BYTE_ARRAY

    BYTE_ARRAY

    STRING

    As a STRING, the bytes are written in base64.

    SHORT, INT, LONG

    INTEGER

    FLOAT, STRING

    A Neo4j integer is 64 bits wide, so the three are the same type.

    FLOAT, DOUBLE

    FLOAT

    STRING

    A Neo4j float is 64 bits wide. A FLOAT is written with its decimal digits, so 0.1 stays 0.1.

    BIG_DECIMAL

    STRING

    FLOAT

    Written as plain text with every digit and no exponent, so that no precision is lost. As a FLOAT it is a 64-bit float, and digits beyond what it holds are lost.

    BOOLEAN

    BOOLEAN

    STRING

    LOCAL_DATE

    DATE

    STRING

    As a STRING, in ISO 8601 (2026-10-21).

    LOCAL_TIME

    LOCAL_TIME

    STRING

    LOCAL_DATE_TIME

    LOCAL_DATETIME

    STRING

    OFFSET_TIME

    ZONED_TIME

    STRING

    OFFSET_DATE_TIME

    ZONED_DATETIME

    LOCAL_DATETIME, STRING

    As LOCAL_DATETIME, the value is converted to UTC and the offset is dropped.

    ARRAY

    LIST

    STRING

    See the notes on lists below.

    MAP

    STRING

    Written as JSON text, because Neo4j cannot store a map as a property.

    • A NULL value removes the property, as described in Writing to Neo4j;

    • Lists. A Neo4j list property holds values of one simple type. The agent drops the NULL elements of a list and writes what is left as a list. A list that mixes types, or has a nested list, a map or bytes in it, cannot be stored as a list, and is written as JSON text instead, with its NULL elements kept. A column set to STRING always receives the JSON text. An empty list is written as an empty list. The elements are written as their default types: integers as INTEGER, floats as FLOAT, decimals as plain text;

    • Maps are JSON text, with dates and times in ISO 8601, bytes in base64, and decimals with every digit;

    • Durations and points are not created by this agent. A Neo4j source reads a duration as ISO 8601 text and a point as a map {srid, x, y}, so a Neo4j to Neo4j pipeline writes the duration as a STRING and the point as JSON text;

    • Dates and times as STRING use the ISO 8601 form of their type.

    Setup via Rest APIs

    Here following an example of calling the Core Hub’s Rest API via curl to setup the connection for this Agent.

    Connect the agent

    curl --location --request PUT 'http://core-hub-ip-address/pipelines/{pipelineId}/agents/{agentId}/config/credentials' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: ••••••' \
    --data '{
        "agentType": "TARGET",
        "agentTag": "neo4j",
        "hostCredentials": {
            "connectionName": "myAgentNickName",
            "host": "neo4j-host-address",
            "port": 7687,
            "databaseName": "neo4j",
            "username": "gluesync",
            "password": "your_password",
            "maxConnectionsCount": 25,
            "enableTls": false
        },
        "customHostCredentials": {
            "uriScheme": "neo4j"
        }
    }'

    For Aura, give the URI of the instance instead of the host and the port:

    {
        "hostCredentials": {
            "connectionName": "myAura",
            "connectionString": "neo4j+s://<id>.databases.neo4j.io",
            "databaseName": "neo4j",
            "username": "neo4j",
            "password": "your_password"
        }
    }

    Notes

    • Every write is a MERGE, so the On duplicate key setting does not apply to this target;

    • Neo4j has no TRUNCATE: the truncate before a snapshot deletes the nodes of the label, with their relationships, or the relationships of the type, in batches;

    • Query Studio is not available on this agent.

    Troubleshooting

    The entity has no key column

    Entity …​ writes nodes with label …​ but has no key column: mark the properties that identify a node as key. Mark the key columns of the entity, or set a logical key. See Setting Logical Keys.

    A relationship entity is refused

    The message names what is missing: the start or end node label, the key mapping of an end (set it, or name the columns start<property> and end<property>), or a mapping that names a column the entity does not have.

    The key column is missing or null

    The key column …​ is null in a …​ A node or a relationship that has no key value cannot be found again, so the change is refused. Check the source column and the key you chose.

    A warning says that rows were not written because an end node is missing

    The entity has Create missing endpoint nodes off, and the start or end node of some relationships is not in the database. The warning names the entity, the number of rows and sample end nodes. Write the node entities first, or turn the setting on. The skipped rows are not retried: snapshot the relationship entity again once the nodes are there.

    A warning says a constraint could not be created

    The warning names the label, the properties and the statement. Run it as an administrator, after you remove the duplicates of the key the data may hold. The entity is written one transaction at a time until the constraint exists. See Constraints.

    Constraint Violation

    A constraint on the key refused a write, for example when two entities write the same label with different keys. The agent tries a refused MERGE up to three times, because the node of the other writer exists the second time. If it persists, check that the entities that share a label use the same key.

    Authentication Failed, Neo4j Unavailable, Database Not Found, Permission Denied

    See Troubleshooting of the source.