INNER CODE UNIT · Python

push

defiprime/defiprime1 · scripts/algolia-index.py:176

def push(client, index, records, temp_index, report=print):
    report(f"copying settings, synonyms and rules from {index} to {temp_index}")
    client.operation(index, "copy", temp_index, scope=COPY_SCOPE)
    batches = batch_records(records, MAX_BATCH_BYTES, MAX_BATCH_RECORDS)
    report(f"uploading {len(records)} records in {len(batches)} batches")
    client.add_objects(temp_index, batches, report=report)
    report(f"moving {temp_index} onto {index}")
    client.operation(temp_index, "move", index)
    report(f"done: {index} now holds {len(records)} records")


def dry_run_report(records, index, app_id, cap):
    biggest, biggest_size = largest_record(records)
    batches = batch_records(records, MAX_BATCH_BYTES, MAX_BATCH_RECORDS)
    lines = [
        f"target index: {index} (app {app_id})",
        f"records: {len(records)}",
        f"total bytes: {total_bytes(records)}",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…