From 2f2cecd16f1da1f0067ab1eec47e63a5265c1bd1 Mon Sep 17 00:00:00 2001 From: mo Date: Fri, 26 Jun 2026 01:24:56 +0000 Subject: [PATCH] infra: neo4j generator creates indexes for fast relationship MERGE --- infra/airflow/scripts/generate_neo4j_graph_data.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/infra/airflow/scripts/generate_neo4j_graph_data.py b/infra/airflow/scripts/generate_neo4j_graph_data.py index 0faafeb..dcf3176 100644 --- a/infra/airflow/scripts/generate_neo4j_graph_data.py +++ b/infra/airflow/scripts/generate_neo4j_graph_data.py @@ -88,6 +88,9 @@ def main(): auth=(DB_USER, DB_PASSWORD)) with driver.session() as session: + # Indexes make relationship MATCH/MERGE fast even with many existing nodes + session.run("CREATE INDEX product_id_idx IF NOT EXISTS FOR (p:Product) ON (p.product_id)") + session.run("CREATE INDEX supplier_id_idx IF NOT EXISTS FOR (s:Supplier) ON (s.supplier_id)") print(f"Generating {TARGET_NODES} product nodes...") print(f"Batch size: {BATCH_SIZE}")