feat: add schema/deployment params to create_index() #589
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates the
create_index()method signature to accept newschemaanddeploymentparameters for the new Full-Text Search API, while maintaining backwards compatibility with the existingspecparameter.Key Changes
New Parameters:
schema: A dict mapping field names to field configurations (using field type classes likeTextField,DenseVectorField)deployment: A deployment configuration object (ServerlessDeployment,PodDeployment, orByocDeployment). Defaults toaws/us-east-1Validation:
specandschemaare mutually exclusive - using both raises an errorNew 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 dictsUsage Examples
Legacy Usage (spec-based):
New Usage (schema-based):
Files Modified
pinecone/db_control/request_factory.py- Added new factory methodspinecone/db_control/resources/sync/index.py- Updated sync create() methodpinecone/db_control/resources/asyncio/index.py- Updated async create() methodpinecone/pinecone.py- Updated wrapper methodpinecone/pinecone_asyncio.py- Updated async wrapper methodpinecone/pinecone_interface_asyncio.py- Updated interface definitionTesting
Added unit tests for:
Related
Note
Medium Risk
Introduces a new index-creation request shape and changes
create_index/index.createargument validation and routing, which can affect backward compatibility and request payloads. Risk is mitigated by keeping the legacyspecpath 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 acceptschemaand optionaldeployment, while makingspecoptional and enforcing exactly one ofspecorschema.Introduces
PineconeDBControlRequestFactory.create_index_with_schema_request()plus_serialize_schema()to build the newCreateIndexRequestpayload (defaulting deployment to serverlessaws/us-east-1and serializing field objects viato_dict). Updates the top-levelPinecone/PineconeAsynciowrappers 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.