Skip to content

Conversation

@rohanshah18
Copy link
Contributor

@rohanshah18 rohanshah18 commented Oct 23, 2025

Problem

This PR updates the Pinecone Java client SDK to align with the 2025-10 OpenAPI specification. The update includes significant model changes, new API capabilities, and infrastructure improvements to support the latest Pinecone features.

Solution

Code Generation Updates

  • Regenerated all API clients based on the 2025-10 OpenAPI specification
  • Fixed code generation naming collisions by adding shell scripts to ensure unique titles in oneOf blocks:
    • Added make_oneof_titles_unique.sh to handle oneOf title uniqueness across the spec
    • Added add_configure_index_request_titles.sh to fix nested object titles in ConfigureIndexRequest schema
  • Updated build scripts to incorporate the new OAS processing steps

Breaking Changes and Updates

Pinecone.java:

  • Changed deletionProtection parameter type: All methods now accept String instead of DeletionProtection enum
    • createServerlessIndex() - now accepts String deletionProtection (e.g., "enabled" or "disabled")
    • createSparseServelessIndex() - now accepts String deletionProtection
    • createIndexForModel() - now accepts String deletionProtection and String cloud (was CloudEnum)
    • createPodsIndex() - all overloads now accept String deletionProtection
    • configurePodsIndex() - overloads now accept String deletionProtection
  • Changed cloud parameter type: createIndexForModel() now accepts String cloud instead of CreateIndexForModelRequest.CloudEnum
  • Removed method overload: Removed one createPodsIndex() overload that took (String, Integer, String, String, String) parameters

Index.java and AsyncIndex.java:

  • Changed errorMode parameter type: startImport() method now accepts String errorMode instead of ImportErrorMode.OnErrorEnum
    • Accepts "abort" or "continue" as string values

Model Classes (If Directly Used):

  • Split model classes: IndexModel, IndexSpec, and ConfigureIndexRequest have been split into type-specific variants:
    • IndexModelPodBased, IndexModelServerless, IndexModelBYOC
    • IndexSpecPodBased, IndexSpecServerless, IndexSpecBYOC
    • ConfigureIndexRequestPodBased, ConfigureIndexRequestServerless
    • Note: This only affects code that directly imports or casts these types. If you're only using the return values from high-level methods, this may not require changes.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

  • All unit tests passing
  • All integration tests passing (pod and serverless)
  • JSON parsing tests updated to handle unknown properties
  • Test fixtures updated to match new API responses


set -eu -o pipefail

# Simple script to add titles to nested objects in ConfigureIndexRequest schema
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I dont add titles, openapi generator will create ConfigureIndexRequestServerless.java and ConfigureIndexRequestServerlessServerless.java classes. And similarly for pod.

…figuration (#202)

## Problem

Add Support for Dedicated Read Capacity (DRN) and Metadata Schema
Configuration

## Solution

This PR adds support for Dedicated Read Capacity (DRN) and Metadata
Schema Configuration for serverless indexes. These features allow users
to:

1. **Configure dedicated read nodes** for better performance and cost
predictability
2. **Limit metadata indexing** to specific fields for improved
performance
3. **Configure read capacity** on existing serverless indexes

#### 1. Create Serverless Index with Read Capacity and Schema

Added overloaded `createServerlessIndex` method that accepts:
- `ReadCapacity` parameter for configuring OnDemand or Dedicated read
capacity
- `BackupModelSchema` parameter for configuring metadata schema

```java
// Create index with Dedicated read capacity
ScalingConfigManual manual = new ScalingConfigManual().shards(2).replicas(2);
ReadCapacityDedicatedConfig dedicated = new ReadCapacityDedicatedConfig()
    .nodeType("t1")
    .scaling("Manual")
    .manual(manual);
ReadCapacity readCapacity = new ReadCapacity(
    new ReadCapacityDedicatedSpec().mode("Dedicated").dedicated(dedicated));

IndexModel indexModel = pinecone.createServerlessIndex(
    indexName, "cosine", 1536, "aws", "us-west-2", 
    "enabled", tags, readCapacity, null);

// Create index with metadata schema
Map<String, BackupModelSchemaFieldsValue> fields = new HashMap<>();
fields.put("genre", new BackupModelSchemaFieldsValue().filterable(true));
fields.put("year", new BackupModelSchemaFieldsValue().filterable(true));
BackupModelSchema schema = new BackupModelSchema().fields(fields);

IndexModel indexModel = pinecone.createServerlessIndex(
    indexName, "cosine", 1536, "aws", "us-west-2", 
    "enabled", tags, null, schema);
```

#### 2. Create Index for Model with Read Capacity and Schema

Added overloaded `createIndexForModel` method that accepts:
- `ReadCapacity` parameter
- `BackupModelSchema` parameter

#### 3. Configure Read Capacity on Existing Index

Enhanced `configureServerlessIndex` method to accept flattened
parameters for easier use:

```java
// Switch to Dedicated read capacity
IndexModel indexModel = pinecone.configureServerlessIndex(
    indexName, "enabled", tags, null, "Dedicated", "t1", 2, 2);

// Switch to OnDemand read capacity
IndexModel indexModel = pinecone.configureServerlessIndex(
    indexName, "enabled", tags, null, "OnDemand", null, null, null);
```

**Note:** Read capacity settings can only be updated once per hour per
index.

### Documentation

- Updated `README.md` with examples for:
  - Creating serverless indexes with dedicated read capacity
  - Creating serverless indexes with OnDemand read capacity
  - Creating serverless indexes with metadata schema
  - Configuring read capacity on existing indexes

## Type of Change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [ ] None of the above: (explain here)

## Test Plan

- Added comprehensive integration tests in
`ReadCapacityAndSchemaTest.java`:
  - Create serverless index with OnDemand read capacity
  - Create serverless index with Dedicated read capacity
  - Create serverless index with metadata schema
  - Create serverless index with both read capacity and schema
  - Create index for model with read capacity and schema
  - Configure read capacity on existing index

- Added helper method `waitUntilReadCapacityIsReady()` in
`TestUtilities.java` to wait for read capacity status to be "Ready"
before configuring (required by API).

- Note: Tests for switching read capacity modes and scaling are omitted
due to API rate limits (once per hour per index).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants