How can I batch-insert many statements that are dependent on each other?


#1

Hello,

the documentation says that insert statements which are dependent on each other can’t be batch-inserted. But this is one of the most common scenarios. Usually when you have relationships, you insert some entities, then the relationship “container” references your inserted entity, for example

insert $entity1 isa something;
insert $entity2 isa something
<define relationship that references $entity1 and $entity2)

What is the best practice to handle this so that I can actually do batch insert? In which cases is batch insert most useful, if it cannot handle the above?

Thanks


Use specific ID in insert query
#2

Hi. I am running into the same issue, and I agree with you, “this is one of the most common scenarios”. I read in the FAQ under section “what is post processing” that entities having the same ids will be later merge in post processing:

  1. insert $a has unique-id ‘1’
  2. insert $b has unique-id ‘1’
  3. insert $c has unique-id ‘1’

It would be possible to create multiple resources of the type unique-id with the value 1. These duplicate resources are similarly merged and resolved by Grakn engine.

However I cannot reproduce this merge. When I batch insert data with same attribute values, I got duplicates. I don’t know if I can say somewhere the attribute should be “unique” in all the grakn keyspace, to force the merge.

I am as stuck as you, I cannot properly ingest many relationships into grakn.