pinecone-io / pinecone-ts-client

The official TypeScript/Node client for the Pinecone vector database
https://www.pinecone.io
Apache License 2.0
166 stars 36 forks source link

List record IDs by prefix #202

Closed austin-denoble closed 4 months ago

austin-denoble commented 4 months ago

Problem

There's a new data plane API for listing record IDs by prefix with pagination that is currently not supported in the TypeScript SDK.

Documentation: https://docs.pinecone.io/docs/get-record-ids

Solution

Bonus:

Type of Change

Test Plan

Verify unit tests and integration tests are passing in CI.

Pull this branch down to manually test using the repl:

Testing listPaginated:

$ npm run repl
$ await init()

const results = await client.index('test-list').namespace('listing').listPaginated({ prefix: 'pre', limit: 10 });
console.log(results);
// {
//   vectors: [
//     { id: 'pre-1' },
//     { id: 'pre-10' },
//     { id: 'pre-100' },
//     { id: 'pre-101' },
//     { id: 'pre-102' },
//     { id: 'pre-103' },
//     { id: 'pre-104' },
//     { id: 'pre-105' },
//     { id: 'pre-106' },
//     { id: 'pre-107' }
//   ],
//   pagination: { next: 'eyJza2lwX3Bhc3QiOiJwcmUtMTA3IiwicHJlZml4IjoicHJlIn0=' },
//   namespace: 'listing',
//   usage: { readUnits: 1 }
// }

// get the next page
await client.index('test-list').namespace('listing').listPaginated({ prefix: 'pre', limit: 10, paginationToken: results.pagination.next})

// {
//   vectors: [
//     { id: 'pre-108' },
//     { id: 'pre-109' },
//     { id: 'pre-11' },
//     { id: 'pre-110' },
//     { id: 'pre-111' },
//     { id: 'pre-112' },
//     { id: 'pre-113' },
//     { id: 'pre-114' },
//     { id: 'pre-115' },
//     { id: 'pre-116' }
//   ],
//   pagination: { next: 'eyJza2lwX3Bhc3QiOiJwcmUtMTE2IiwicHJlZml4IjoicHJlIn0=' },
//   namespace: 'listing',
//   usage: { readUnits: 1 }
// }