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.

Get bulk upsert information

First, get the required information to upload payload to object storage:
from lambdadb import LambdaDB

lambda_db = LambdaDB(
    server_url="PROJECT_URL",
    project_api_key="YOUR_API_KEY"
)

get_bulk_upsert = lambda_db.collections.docs.get_bulk_upsert(
    collection_name=collection_name
)
The response will look like this:
{
  "url": "<string>",
  "type": "application/json",
  "httpMethod": "PUT",
  "objectKey": "<string>",
  "sizeLimitBytes": 209715200
}

Upload documents and execute bulk upsert

Upload your documents as a one object using the provided URL and call bulk-upsert API with the corresponding objectKey:
import json
import requests

docs = [
  {
    "id": "bulk_33201222",
    "url": "https://en.wikipedia.org/wiki/LambdaDB",
    "title": "LambdaDB",
    "text": "LambdaDB is a serverless-native search engine for AI... ",
    "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 documents to the provided URL
put_documents = requests.put(
    get_bulk_upsert.url,
    data=json.dumps({"docs": docs}),
    headers={"Content-Type": "application/json"},
)

# Execute bulk upsert
bulk_upsert = lambda_db.collections.docs.bulk_upsert(
    collection_name=collection_name, 
    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. It may take some time for the documents to be fully indexed and available for search.