Configuring Metadata Indexing

1. Defining Indexed Fields

Example: Pod Selective Indexing

from pinecone import PodSpec

pc.create_index(
    name="docs",
    dimension=1536,
    metric="cosine",
    spec=PodSpec(
        environment="us-east-1-aws",
        pod_type="p1.x1",
        metadata_config={"indexed": ["source", "language", "published"]},
    ),
)
NoteDetail
Pod onlyServerless indexes all fields
Set at creationCannot change later

2. Indexing String Fields

RecommendationReason
Low cardinalityFaster filters (e.g., enums)
Avoid free textUse sparse vectors instead
Case-sensitiveNormalize before storing

3. Indexing Numeric Fields

UseExample
Range filterprice, timestamp, score
Equalityyear, version

4. Indexing Boolean Fields

PatternUse
published / draftVisibility filter
deleted / activeSoft delete
featuredBoost / curate

5. Understanding Non-Indexed Metadata

Note: Non-indexed metadata is returned with results but cannot be used in filter. Useful for large text snippets or auxiliary data.
Field TypeWhy Skip Indexing
Long text snippetBloats filter index, never filtered
Source URLDisplay only
JSON blobStored but not filterable

6. Configuring at Index Creation

Example: Node.js Pod with Indexed Fields

await pc.createIndex({
  name: "docs",
  dimension: 1536,
  metric: "cosine",
  spec: { pod: { environment: "us-east-1-aws", podType: "p1.x1",
    metadataConfig: { indexed: ["source", "language"] } } },
});

7. Understanding Metadata Performance Impact

AspectEffect
Index sizeGrows with indexed fields × cardinality
Query latencyLower with selective indexing
Upsert speedSlower with many indexed fields

8. Optimizing Metadata Indexes

TipReason
Index only filtered fieldsSmaller, faster index
Bucket high-cardinality numberse.g., price range buckets
Use booleans/enumsHighest filter performance

9. Handling Metadata Size Limits

LimitWorkaround
40 KB / vectorStore large text externally; keep ID reference
Field countNo hard limit; size cap applies

10. Managing Metadata Schema Evolution

Schema Migration

  1. Add new field to upsert pipeline (backward compatible).
  2. Backfill existing vectors with update(set_metadata=...).
  3. Switch read path to use new field.
  4. Remove old field reads; optionally backfill removal.
Change TypeStrategy
Add fieldBackfill or default-on-read
Rename fieldWrite both, migrate readers, drop old
Re-type fieldRecreate index (no in-place type change)