Skip to main content
Besides the upsert operation which has 6MB maximum payload size limit, LambdaDB also supports bulk upsert operation to insert or update multiple documents up to 200MB at once. The easiest way to bulk upsert is to use the SDK’s one-step method. The client uploads your documents to the presigned URL and completes the bulk upsert for you (up to 200MB).
from lambdadb import LambdaDB

with LambdaDB(
    project_api_key="YOUR_API_KEY",
    base_url="YOUR_BASE_URL",
    project_name="YOUR_PROJECT_NAME",
) as client:
    coll = client.collection("my_collection")
    docs = [
        {"id": "bulk_1", "url": "https://en.wikipedia.org/wiki/LambdaDB", "title": "LambdaDB", "text": "LambdaDB is an AI-native database ... ", "dense_vector": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], "sparse_vector": {"LambdaDB": 0.83, "is": 0.1, "a": 0.1, "AI": 0.7}},
        {"id": "bulk_2", "url": "https://en.wikipedia.org/wiki/Winamp", "title": "Winamp", "text": "Winamp is a media player for Windows, macOS and Android ...", "dense_vector": [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]},
    ]
    coll.docs.bulk_upsert_docs(docs=docs)
After a successful request you’ll receive a message such as "Upsert request is accepted". Documents are processed asynchronously and become searchable after indexing completes.

Two-step: Get presigned URL, then upload and complete

If you need to control the upload yourself (e.g. from a different process or storage), use this flow: (1) get bulk upsert info (presigned URL and objectKey), (2) upload the payload to the presigned URL, then (3) call the bulk-upsert API with the objectKey.

Step 1: Get bulk upsert information

from lambdadb import LambdaDB

with LambdaDB(
    project_api_key="YOUR_API_KEY",
    base_url="YOUR_BASE_URL",
    project_name="YOUR_PROJECT_NAME",
) as client:
    coll = client.collection("my_collection")
    get_bulk_upsert = coll.docs.get_bulk_upsert()
    # get_bulk_upsert.url, get_bulk_upsert.object_key, get_bulk_upsert.size_limit_bytes
Response:
{
  "url": "<string>",
  "type": "application/json",
  "httpMethod": "PUT",
  "objectKey": "<string>",
  "sizeLimitBytes": 209715200
}

Step 2: Upload to presigned URL and call bulk-upsert

Upload the document list as JSON to the url (PUT), then call the bulk-upsert API with the objectKey from step 1.
import json
import requests

docs = [
    {"id": "bulk_33201222", "url": "https://en.wikipedia.org/wiki/LambdaDB", "title": "LambdaDB", "text": "LambdaDB is an AI-native database ... ", "dense_vector": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], "sparse_vector": {"LambdaDB": 0.83, "is": 0.1, "a": 0.1, "AI": 0.7}},
]
# Upload to presigned URL
resp = requests.put(
    get_bulk_upsert.url,
    data=json.dumps({"docs": docs}),
    headers={"Content-Type": "application/json"},
)
resp.raise_for_status()
# Complete bulk upsert
coll.docs.bulk_upsert(object_key=get_bulk_upsert.object_key)

Response

After successful bulk upsert initiation you’ll receive:
{
  "message": "Bulk upsert request is accepted"
}
Bulk upsert operations are processed asynchronously in the background. Consequently, newly uploaded documents may not be immediately available for search or fetch requests, even if consistentRead is set to true. The documents will become available only after the indexing process is fully complete.