Skip to main content
This page shows you how to upsert documents into a collection.
from lambdadb import LambdaDB

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

docs = [
  {
    "id": "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}
  },
  {
    "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],
    "sparse_vector" : {"0": 0.8, "4": 0.1, "11": 0.1, "63": 0.54}
  }
]

upsert_documents_test = lambda_db.collections.docs.upsert(
    collection_name=collection_name, 
    docs=docs
)

Response

{
  "message": "Upsert request is accepted"
}
Each document implicitly contains an id field in order to uniquely identify a document. A unique string value is auto-generated by the system if id field is not provided in an upsert request. If you want to overwrite the entire document, you can do so by providing the id field in the document.
For a partitioned collection, documents are upserted into __default__ partition if partition field is not provided.

Upsert limits

MetricLimit
Max payload size6MB
Max length for a document ID512 characters
Max vector dimensions4,096
Max document size5MB
When upserting larger amounts of data, it is recommended to use bulk-upsert operation.