Skip to content

Commit

Permalink
Prep for release v2.1.0 and add proxy config & disabling TLS examples…
Browse files Browse the repository at this point in the history
… to README (#152)

## Problem

- Prepare for releasing v2.1.0.
- Added support proxy configuration and for disabling TLS, so add
examples to the README.

## Solution

- Update pinecone client version to `v2.1.0`.
- Add proxy config and disabling TLS examples to README

## Type of Change

- [X] Non-code change (docs, etc)

## Test Plan

NA
  • Loading branch information
rohanshah18 authored Sep 18, 2024
1 parent c75a0df commit 27ea488
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

[comment]: <> (When bumping [pc:VERSION_LATEST_RELEASE] create a new entry below)
### Unreleased version
### 2.1.0
- Add support to disable TLS for data plane operations

### 2.0.0
- Add deletion protection

Expand Down
83 changes: 80 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Maven:

Gradle:
```
implementation "io.pinecone:pinecone-client:1.2.2"
implementation "io.pinecone:pinecone-client:2.0.0"
```

[comment]: <> (^ [pc:VERSION_LATEST_RELEASE])
Expand Down Expand Up @@ -61,7 +61,11 @@ public class InitializeClientExample {
}
```

#### Passing OkHttpClient
#### Passing OkHttpClient for control plane operations

If you need to provide a custom `OkHttpClient`, you can do so by using the `withOkHttpClient()` method of the
`Pinecone.Builder` class to pass in your `OkHttpClient` object.

```java
import io.pinecone.clients.Pinecone;

Expand All @@ -79,14 +83,84 @@ public class InitializeClientExample {
}
```

#### Configuring HTTP proxy for both control and data plane operations

If your network setup requires you to interact with Pinecone via a proxy, you will need to pass additional
configuration using the parameters `host` and `port` of the `ProxyConfig` class.

```java
import io.pinecone.clients.Index;
import io.pinecone.clients.Pinecone;
import io.pinecone.proto.UpsertResponse;
import io.pinecone.unsigned_indices_model.QueryResponseWithUnsignedIndices;
import org.openapitools.control.client.model.IndexModel;

import java.util.Arrays;

public class ProxyExample {
public static void main(String[] args) {
String apiKey = "PINECONE_API_KEY";
String proxyHost = "PROXY_HOST";
int proxyPort = 8080; // Port can be configured based on your setup

Pinecone pinecone = new Pinecone.Builder(apiKey)
.withProxy(proxyHost, proxyPort)
.build();

// Control plane operation routed through the proxy server
IndexModel indexModel = pinecone.describeIndex("PINECONE_INDEX");

// Data plane operations routed through the proxy server
Index index = pinecone.getIndexConnection("PINECONE_INDEX_NAME");
// 1. Upsert data
UpsertResponse upsertResponse = index.upsert("v1", Arrays.asList(1F, 2F, 3F, 4F));
// 2. Query vector
QueryResponseWithUnsignedIndices queryResponse = index.queryByVectorId(1, "v1", true, true);
}
}
```

#### Disabling SSL verification for data plane operations

If you would like to disable TLS verification for data plane operations, you can disable it by setting `enableTLS`
parameter of `PineconeConfig` class to false. We do not recommend going to production with TLS verification disabled.

```java
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import io.pinecone.unsigned_indices_model.QueryResponseWithUnsignedIndices;
import io.pinecone.proto.UpsertResponse;
import java.util.Arrays;

public class DisableTLSExample {
public static void main(String[] args) {
PineconeConfig config = new PineconeConfig("api");
config.setHost("localhost:5081");
config.setTLSEnabled(false);
PineconeConnection connection = new PineconeConnection(config);
Index index = new Index(connection, "example-index");

// Data plane operations
// 1. Upsert data
UpsertResponse upsertResponse = index.upsert("v1", Arrays.asList(1f, 2f, 3f));
// 2. Query data
QueryResponseWithUnsignedIndices queryResponse = index.queryByVectorId(1, "v1", true, true);
}
}
```

# Indexes

Operations related to the building and managing of Pinecone indexes are called [control plane](https://docs.pinecone.io/reference/api/introduction#control-plane) operations.

## Create Index

You can use the Java SDK to create two types of indexes: [serverless indexes](https://docs.pinecone.io/guides/indexes/understanding-indexes#serverless-indexes) (recommended for most use cases) and
[pod-based indexes](https://docs.pinecone.io/guides/indexes/understanding-indexes#pod-based-indexes) (recommended for high-throughput use cases).

### Create a serverless index

The following is an example of creating a serverless index in the `us-west-2` region of AWS. For more information on
serverless and regional availability, see [Understanding indexes](https://docs.pinecone.io/guides/indexes/understanding-indexes#serverless-indexes).

Expand All @@ -109,6 +183,7 @@ IndexModel indexModel = pinecone.createServerlessIndex(indexName, similarityMetr
```

### Create a pod index

The following is a minimal example of creating a pod-based index. For all the possible configuration options, see
`main/java/io/pinecone/clients/Pinecone.java`.

Expand All @@ -131,6 +206,7 @@ IndexModel indexModel = pinecone.createPodsIndex(indexName, dimension, environme
```

### Create a pod index with deletion protection enabled

The following is an example of creating a pod-based index with deletion protection enabled. For all the possible
configuration options, see `main/java/io/pinecone/clients/Pinecone.java`.

Expand All @@ -150,7 +226,6 @@ String podType = "p1.x1";
IndexModel indexModel = pinecone.createPodsIndex(indexName, dimension, environment, podType, DeletionProtection.ENABLED);
```


## List indexes

The following example returns all indexes (and their corresponding metadata) in your project.
Expand Down Expand Up @@ -369,6 +444,7 @@ FetchResponse fetchResponse = index.fetch(ids, "example-namespace");
```

## List vector IDs

The following example lists up to 100 vector IDs from a Pinecone index.

This method accepts optional parameters for `namespace`, `prefix`, `limit`, and `paginationToken`.
Expand Down Expand Up @@ -407,6 +483,7 @@ UpdateResponse updateResponse = index.update("v1", values, "example-namespace");
```

# Collections

Collections fall under data plane operations.

## Create collection
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pineconeClientVersion = 2.0.0
pineconeClientVersion = 2.1.0
2 changes: 1 addition & 1 deletion src/main/java/io/pinecone/commons/Constants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.pinecone.commons;

public class Constants {
public static final String pineconeClientVersion = "v2.0.0";
public static final String pineconeClientVersion = "v2.1.0";
}

0 comments on commit 27ea488

Please sign in to comment.