Method Overloads
Pattern 1: VectorItem Array
Parameters
Pattern 1: VectorItem Array
Parameter | Type | Description |
---|---|---|
items | VectorItem[] | Array of vector items to insert or update in the index |
Pattern 2: Parallel Arrays
Parameter | Type | Description |
---|---|---|
ids | string[] | Array of ID strings for each vector |
vectors | number[][] | Array of vector embeddings corresponding to each ID |
VectorItem Structure
EachVectorItem
must contain an id
and vector
, with optional fields:
Field | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique identifier for the vector item |
vector | number[] | Yes | The vector representation |
contents | string | Buffer | Optional | Original text or binary content associated with the vector |
metadata | object | Optional | Additional structured data associated with the vector |
Returns
Promise<object>
: A Promise that resolves to a response object containing the operation status and message with the count of upserted vectors.
Exceptions
Error
Error
- Throws if the API request fails due to network connectivity issues.
- Throws if authentication fails (invalid API key).
- Throws if the encryption key is invalid for the specified index.
- Throws if there are internal server errors preventing the upsert.
Validation Errors
Validation Errors
- Throws detailed validation errors for invalid VectorItem objects.
- Throws if vector dimensions don’t match the index configuration.
- Throws if required fields are missing from vector items.
- Throws if array lengths don’t match in parallel array format.
- Throws if vector elements are not finite numbers.