Skip to content

RelationshipSet API Reference

The RelationshipSet class is used for bulk loading relationships into Neo4j. It provides methods for adding relationships between nodes and loading them efficiently.

Class Definition

RelationshipSet

RelationshipSet(rel_type: str, start_node_labels: list[str], end_node_labels: list[str], start_node_properties: list[str], end_node_properties: list[str], default_props: dict = None, append_props: list[str] = None)

Container for a set of Relationships with the same type of start and end nodes.

Parameters:

Name Type Description Default
rel_type str

Realtionship type.

required
start_node_labels list[str]

Labels of the start node.

required
end_node_labels list[str]

Labels of the end node.

required
start_node_properties list[str]

Property keys to identify the start node.

required
end_node_properties list[str]

Properties to identify the end node.

required
append_props list[str]

Properties that should be appended as arrays during MERGE

None

add_relationship

add_relationship(start_node_properties, end_node_properties, properties: dict = None)

Add a relationship to this RelationshipSet.

Parameters:

Name Type Description Default
start_node_properties

Start node properties as dict or OGM instance.

required
end_node_properties

End node properties as dict or OGM instance.

required
properties dict

Relationship properties.

None

create

create(graph, database=None, batch_size=None)

Create relationships in this RelationshipSet

merge

merge(graph, database=None, batch_size=None, append_props=None)

Merge relationships in this RelationshipSet.

Parameters:

Name Type Description Default
append_props

Properties that should be appended as arrays during MERGE.

None

create_index

create_index(graph, database=None)

Create indices for start node and end node definition of this relationshipset. If more than one start or end node property is defined, all single property indices as well as the composite index are created.