Working with Namespaces

1. Understanding Default Namespace

PropertyBehavior
NameEmpty string ""
CreatedImplicit, always present
Used whennamespace param omitted

2. Creating Implicit Namespaces

Example: Namespace on First Upsert

index.upsert(vectors=[{"id": "1", "values": [...]}],
             namespace="tenant-99")  # created if missing
RuleDetail
No explicit create APINamespaces appear on first upsert
Name constraintsAlphanumeric + -_; max 128 chars

3. Listing Namespace Statistics

Example: Per-Namespace Counts

stats = index.describe_index_stats()
for ns, info in stats["namespaces"].items():
    print(ns or "(default)", info["vector_count"])

4. Querying Specific Namespace

Example: Scoped Query

res = index.query(vector=qv, top_k=5, namespace="tenant-a")
BehaviorDetail
Default scopeSingle namespace per query
Cross-namespaceRun N queries, merge client-side

5. Upserting to Namespace

Example: Multi-Tenant Upsert

for tenant_id, vecs in tenant_data.items():
    index.upsert(vectors=vecs, namespace=f"tenant-{tenant_id}")

6. Deleting Namespace Contents

GoalAPI
Empty namespaceindex.delete(delete_all=True, namespace="x")
Remove namespaceindex.delete_namespace("x") (serverless)

7. Organizing Data with Namespaces

PatternUse Case
Per-tenantSaaS multi-tenancy; isolate user data
Per-languageLocalized embeddings
Per-versionA/B testing embedding models
Per-environmentdev / staging / prod

8. Managing Namespace Isolation

Warning: Namespaces share the index API key. For strong isolation between untrusted tenants, use separate indexes or projects.
ConcernMitigation
Accidental cross-tenant queryEnforce namespace at API gateway
Noisy neighborPinecone isolates compute per index, not per namespace

9. Querying Across Namespaces

Example: Merge Results

matches = []
for ns in ["a", "b", "c"]:
    res = index.query(vector=qv, top_k=10, namespace=ns)
    matches += res["matches"]
matches.sort(key=lambda m: m["score"], reverse=True)
top10 = matches[:10]

10. Optimizing Namespace Usage

TipReason
Group small tenantsAvoid 100K+ tiny namespaces
Use metadata for sub-groupingWithin a namespace
Drop empty namespacesReduce admin overhead