This version of the Pinecone Java SDK introduces support for specifying a base URL for control and data plane operations.
Features
Support to pass base url for control and data plane operations
Users can now specify the base URL (host:port) for both control and data plane operations using the Builder
inner class of the Pinecone
class. This is achieved with the withHost()
method, supporting both HTTP
and HTTPS
endpoints. For HTTP
endpoints on the data plane, users must also disable TLS
using the withTlsEnabled()
method.
The following example demonstrates how to perform control and data plane operations against a locally running emulator:
import io.pinecone.clients.Index;
import io.pinecone.clients.Pinecone;
import io.pinecone.configs.PineconeConfig;
import org.openapitools.db_control.client.ApiClient;
import org.openapitools.db_control.client.api.ManageIndexesApi;
import org.openapitools.db_control.client.model.DeletionProtection;
import java.util.Arrays;
...
String host = "http://localhost:5080";
Pinecone pinecone = new Pinecone.Builder("apiKey")
.withHost(host) // set host to localhost and port to 5080
.withTlsEnabled(false) // disable TLS for data plane operations
.build();
// Create serverless index
pinecone.createServerlessIndex("serverless-index", "cosine", 3, "aws","us-east-1", DeletionProtection.DISABLED);
// Create pod index
pinecone.createPodsIndex("pod-index", 3, "us-east-1-aws", "p1.x1");
// Describe serverless index
pinecone.describeIndex("serverless-index");
// Describe pod index
pinecone.describeIndex("pod-index");
// Get index connection object for serverless-index
Index serverlessIndexConnection = pinecone.getIndexConnection("serverless-index");
// Get index connection object for pod-index
Index podIndexConnection = pinecone.getIndexConnection("pod-index");
// Upsert records into serverless index
serverlessIndexConnection.upsert("v1", Arrays.asList(1f, 2f, 3f));
// Upsert records into pod index
podIndexConnection.upsert("v1", Arrays.asList(1f, 2f, 3f));
// Query by vectorId from serverless index
serverlessIndexConnection.queryByVectorId(3, "v1");
// Query by vectorId from pod index
podIndexConnection.queryByVectorId(3, "v1");
// Delete serverless index
pinecone.deleteIndex("serverless-index");
// Delete pod index
pinecone.deleteIndex("pod-index");
What's Changed
Full Changelog: v2.1.0...v3.0.0
What's Changed
- Update import examples in README by @jseldess in #167
- support default namespace for list api by @nianliuu in #157
- Add support for passing base path for control plane operations by @rohanshah18 in #168