Skip to main content
A collection is a named container that groups related memories together. You create collections, assign memories to them, and scope searches to them.

Why Use Collections?

  • Separate contexts: Keep work, personal, and project memories distinct
  • Targeted search: Search only within relevant collections
  • Access control: Different API keys can have different collection permissions
  • Multi-tenancy: Isolate data for different users or customers

Creating Collections

Collection names are case-insensitive. “Work” and “work” are treated as duplicates.
from nebula import Nebula, Memory
nebula = Nebula()

collection = nebula.create_collection(
    name="Research Papers",
    description="Academic research documents"
)

Storing Memories in Collections

Always specify collection_id when storing memories:
nebula.store_memory(
    Memory(
        collection_id=collection.id,
        content="Q4 planning meeting notes",
        metadata={"type": "meeting"}
    )
)

Searching Within Collections

# Search specific collection
results = nebula.search(query="deadlines", collection_ids=["Work"])

# Search multiple collections
results = nebula.search(query="notes", collection_ids=["Work", "Personal"])

# Search all accessible collections
results = nebula.search(query="important")
Search accepts collection names or UUIDs. When storing memories, collection_id must be a UUID.

Managing Collections

collections = nebula.list_collections(limit=50)
work_collections = nebula.list_collections(name="Work")

Patterns and Tips

PatternWhen to Use
One collection per userUser-specific memory/context
One collection per projectProject-scoped documentation
One collection per data typeDifferent content types (docs, chats, notes)