You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
723 B

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)