INNER CODE UNIT · Python
operation
defiprime/defiprime1 · scripts/algolia-index.py:159
def operation(self, source, operation, destination, scope=None):
payload = {"operation": operation, "destination": destination}
if scope is not None:
payload["scope"] = scope
response = self.post(
f"/1/indexes/{source}/operation",
json.dumps(payload, separators=(",", ":")).encode("utf-8"),
)
self.wait(source, response["taskID"])
def add_objects(self, index, batches, report=print):
for position, batch in enumerate(batches, 1):
response = self.post(f"/1/indexes/{index}/batch", batch_body(batch))
self.wait(index, response["taskID"])
report(f"batch {position}/{len(batches)}: {len(batch)} records")
def push(client, index, records, temp_index, report=print):