Fastest way to map nodes and edges into RedisGraph

Hello all,
I have hashes structured as node{id}={‘id’:id, ‘name’:name, ‘rank’}
and edges{id}:source_id, destination_id=, sentence_id, rank=int.
They map directly into RedisGraph nodes and edges, what would be the fastest way to batch map from Redis into Redis graph?
I am worried about:
redis_graph.commit() in example.
Does it mean Graph can only be populated in batches?

1 Like

In case your data is already in Redis LUA Script might be a valid option reading data from hash and populating a graph key,
Another option would be reading the data out of Redis, constructing a set of CSV files complying with our Bulk-Loader utility.

In case you’ve only have a handful of entities then either RedisGraph client will do the trick,
Lastly a graph is not restricted to batch loading.

1 Like

Hello @SWilly22 thank you for reply.
Do you have example of Lua script which does something similar?
I am trying to use python redisgraph client “on-demand” but the number of entities is fairly large - mostly edges, I would rather prepare hash first and bulk load from. I have seen BuilkLoader script and looking at source code right now, but it seems a bit nonoptimal dump redis into CSV only to load back to Redis.

I’ll suggest starting here
basically you should be able to use LUA to read hash keys and issue GRAPH.QUERY calls.

1 Like

@SWilly22 thank you for your suggestion. One follow up question: do I have to check for the existence of node or edge inside RedisGraph before issuing GRAPH.QUERY CREATE command? In other words - if duplicate crated requests are taken care automatically, do they have performance penalty?

To avoid duplicates use the MERGE clause.