from arango_client import arango chunks_collection = arango.db.collection("chunks") q = """ FOR chunk IN chunks FILTER chunk.parent_id == null RETURN chunk """ cursor = arango.db.aql.execute(q, batch_size=1000, count=True, ttl=360) updated_docs = [] n = 0 for doc in cursor: n += 1 doc['collection'] = 'talks' del doc['chroma_collecton'] del doc['chroma_id'] doc['parent_id'] = f"talks/{doc['_key'].split(':')[0]}" updated_docs.append(doc) if len(updated_docs) >= 100: chunks_collection.update_many(updated_docs, merge=False, silent=True) updated_docs = [] print(f"Updated {n} documents", end="\r") chunks_collection.update_many(updated_docs, merge=False, silent=True)