Skip to content

Conversation

@jhamon
Copy link
Collaborator

@jhamon jhamon commented Jan 30, 2026

Summary

This PR updates the create_index() method signature to accept new schema and deployment parameters for the new Full-Text Search API, while maintaining backwards compatibility with the existing spec parameter.

Key Changes

  • New Parameters:

    • schema: A dict mapping field names to field configurations (using field type classes like TextField, DenseVectorField)
    • deployment: A deployment configuration object (ServerlessDeployment, PodDeployment, or ByocDeployment). Defaults to aws/us-east-1
  • Validation: spec and schema are mutually exclusive - using both raises an error

  • New Request Factory Methods:

    • create_index_with_schema_request() - creates index requests in the new schema-based format
    • _serialize_schema() - helper to serialize field type objects to dicts

Usage Examples

Legacy Usage (spec-based):

from pinecone import ServerlessSpec

pc.create_index(
    name="my-index",
    dimension=1536,
    metric="cosine",
    spec=ServerlessSpec(cloud="aws", region="us-east-1")
)

New Usage (schema-based):

from pinecone import TextField, DenseVectorField, ServerlessDeployment

pc.create_index(
    name="my-index",
    schema={
        "title": TextField(full_text_searchable=True),
        "embedding": DenseVectorField(dimension=1536, metric="cosine"),
    }
    # deployment defaults to aws/us-east-1 if omitted
)

# Or with custom deployment:
pc.create_index(
    name="my-index",
    schema={
        "content": TextField(full_text_searchable=True),
        "embedding": DenseVectorField(dimension=1536, metric="cosine"),
    },
    deployment=ServerlessDeployment(cloud="gcp", region="us-central1"),
)

Files Modified

  • pinecone/db_control/request_factory.py - Added new factory methods
  • pinecone/db_control/resources/sync/index.py - Updated sync create() method
  • pinecone/db_control/resources/asyncio/index.py - Updated async create() method
  • pinecone/pinecone.py - Updated wrapper method
  • pinecone/pinecone_asyncio.py - Updated async wrapper method
  • pinecone/pinecone_interface_asyncio.py - Updated interface definition

Testing

Added unit tests for:

  • Parameter validation (mutual exclusion of spec/schema)
  • Request routing to correct factory method
  • Schema serialization with field type objects
  • Schema serialization with dict format
  • Custom deployment configurations

Related

  • Linear: SDK-106
  • Depends on: SDK-104, SDK-105 (both merged)

Note

Medium Risk
Introduces a new index-creation request shape and changes create_index/index.create argument validation and routing, which can affect backward compatibility and request payloads. Risk is mitigated by keeping the legacy spec path and adding targeted unit tests.

Overview
Adds support for the new schema-based index creation API by extending create_index/index.create (sync + asyncio) to accept schema and optional deployment, while making spec optional and enforcing exactly one of spec or schema.

Introduces PineconeDBControlRequestFactory.create_index_with_schema_request() plus _serialize_schema() to build the new CreateIndexRequest payload (defaulting deployment to serverless aws/us-east-1 and serializing field objects via to_dict). Updates the top-level Pinecone/PineconeAsyncio wrappers and asyncio interface signatures accordingly, and adds unit tests covering validation, routing, deployment defaults/customization, and schema serialization error handling.

Written by Cursor Bugbot for commit 3e11730. This will update automatically on new commits. Configure here.

Update the `create_index()` method signature to accept new `schema` and
`deployment` parameters while maintaining backwards compatibility with the
existing `spec` parameter.

Key changes:
- Add `schema` and `deployment` params to create_index() methods
- Add validation for mutual exclusion of spec and schema
- Add create_index_with_schema_request() factory method
- Add _serialize_schema() helper method
- Add unit tests for validation and routing logic

Refs: SDK-106
@jhamon jhamon added the enhancement New feature or request label Jan 30, 2026
@jhamon jhamon merged commit 0ee543f into fts Jan 30, 2026
7 checks passed
@jhamon jhamon deleted the jhamon/sdk-106-update-create_index-signature branch January 30, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant