You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "hammadsaleemm (via GitHub)" <gi...@apache.org> on 2023/05/14 10:27:38 UTC

[GitHub] [age] hammadsaleemm commented on issue #918: How to add multiple edges in single query faster?

hammadsaleemm commented on issue #918:
URL: https://github.com/apache/age/issues/918#issuecomment-1546865311

   Yes, you can use a single Cypher query to add multiple edges at a time in Neo4j graph database. The Cypher query language provides several ways to create multiple edges efficiently. My take is on UNWINDIND
   
   One common way is to use the UNWIND clause to create multiple edges at once from a collection of edge properties. Here is an example: `UNWIND [{source: 1, target: 2}, {source: 2, target: 3}, {source: 3, target: 1}] AS edge
   MATCH (s:Node {id: edge.source}), (t:Node {id: edge.target})
   CREATE (s)-[:CONNECTS_TO]->(t)
   `
   In this example, the UNWIND clause unpacks a list of edge properties, each containing the source and target nodes' ids. The MATCH clause finds the corresponding nodes in the graph, and the CREATE clause creates the CONNECTS_TO relationship between them.
   
   You can modify this query to add any other properties to the edges as needed. You can also adjust the MATCH clause to use different node labels or property names, depending on your graph's schema.
   
   Note that adding multiple edges at once can still be slow if you have a large number of nodes or edges. In that case, you may want to consider using bulk import tools or using Neo4j's apoc library to optimize the import process.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org