This page shows you how to create a collection with various configurations.

Parameters

ParameterTypeRequiredDescription
collectionNamestringCollection name must be unique within a project and the supported maximum length is 52
indexConfigsobjectField configuration for indexing. Required when creating from scratch
sourceProjectNamestringSource project name for PITR or cloning operations
sourceCollectionNamestringSource collection name for PITR or cloning operations
sourceDatetimestringISO 8601 formatted datetime for PITR (e.g., “2024-01-15T10:30:00Z”)
sourceProjectApiKeystringAPI key for the source project

Create a collection from scratch

The simplest way to create a collection is to provide the collection name and the field index configurations.
from lambdadb import LambdaDB

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

basic_config = {
    "url": {"type": models.Type.KEYWORD},
    "author": {"type": models.Type.KEYWORD},
    "content": {
      "type": models.TypeText.TEXT,
      "analyzers": [
          models.Analyzer.JAPANESE,
          models.Analyzer.KOREAN,
          models.Analyzer.ENGLISH,
      ],
    }
}

collection = lambda_db.collections.create(
    collection_name="example-collection",
    index_configs=basic_config
)

Clone a collection with point-in-time recovery (PITR)

LambdaDB automatically maintains continuous backups at the collection level with a default retention period of 30 days. You can create a collection from a specific point in time using PITR functionality.
from lambdadb import LambdaDB
from datetime import datetime

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

# Restore from a specific point in time
restored_collection = lambda_db.collections.create(
    collection_name="restored-collection",
    source_project_name="source-project-name",
    source_project_api_key="YOUR_SOURCE_API_KEY"
    source_collection_name="source-collection-name",
    source_datetime="2024-01-15T10:30:00Z",
)
PITR allows you to restore collections to any point within the configured retention period. The sourceDatetime parameter must be in ISO 8601 format (UTC timezone). If sourceDatetime is not specified, the collection will be restored from the most recent data available.

Clone a collection with additional index configs

You can clone a collection based on an existing collection and extend it with additional indexConfigs. The original collection’s configuration will be preserved, and you can only add new fields.
from lambdadb import LambdaDB

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

cloned_collection = lambda_db.collections.create(
    collection_name="cloned-collection",
    source_project_id="example-source-project-id",
    source_project_api_key="YOUR_SOURCE_API_KEY",
    source_collection_name="example-source-collection-name"
    index_configs={
      "newText": {
        "type": "text,
        "analyzers": [
            "japanese",
            "korean",
            "english"
        ],
    },
    }
    source_datetime="2025-08-08T10:00:00Z"
)
When cloning a collection, specifying indexConfigs is optional. You can pass additional indexConfigs to extend the original collection’s configuration, but deleting or modifying the original collection’s indexConfigs is not allowed.