Update
Updates an existing vector's values or metadata in a Pinecone index. Use this when you need to modify a vector without changing its ID.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Connection Id - Connection identifier from Connect node (optional if API Key credential is provided directly).
- Host URL - Your index's host URL. Format:
https://INDEX_NAME-PROJECT_ID.svc.ENVIRONMENT.pinecone.io. You can find this in your Pinecone console. - Id - The unique ID of the vector to update. Must already exist in the index.
- Values - New vector values array (same dimension as index). The vector embedding data to update.
Options
- API Key - Pinecone API key credential (optional - use this instead of Connection Id if not using Connect node).
- Metadata - New metadata object to set for the vector. This will replace the existing metadata entirely.
- Name Space - Namespace containing the vector to update. Optional, defaults to the default namespace.
Output
- Response - Object confirming the update operation (typically an empty object
{}).
How It Works
The Update node modifies an existing vector in your Pinecone index. When executed, the node:
- Validates required inputs (Host URL, Id, Values)
- Constructs the update request with new values and optional metadata
- Sends a POST request to the index's
/vectors/updateendpoint - Returns a confirmation response
Requirements
- An existing Pinecone index with data
- A valid vector ID that exists in the index
- New vector values with the same dimension as the index
- The vector must exist in the specified namespace
Error Handling
The node will return specific errors in the following cases:
- ErrInvalidArg - Host URL is empty
- ErrInvalidArg - Id is empty
- ErrInvalidArg - Invalid Connection ID or missing API key
- ErrInternal - Response format is not valid
- ErrStatus - HTTP error from Pinecone API (vector not found, dimension mismatch, etc.)
Usage Notes
- The vector ID must already exist (Update won't create new vectors - use Upsert for that)
- If Values is provided, it must match the index dimension
- You can update just metadata by providing only metadata without values
- Metadata update replaces the entire metadata object, not just specified fields
- The update is atomic - either all changes succeed or none do
- Updates are eventually consistent
Update vs Upsert
Use Update when:
- You want to modify an existing vector
- You need to ensure the vector exists before modifying
- You want explicit error if vector doesn't exist
Use Upsert when:
- You want to insert or update (create if not exists)
- You're batch loading data
- You don't care if the vector already exists
Best Practices
- Verify the vector exists before updating (use Fetch)
- Keep the same dimension when updating values
- Use descriptive metadata fields
- Document why updates are happening
- Consider using Upsert for simpler logic unless you specifically need Update behavior
- Batch updates when possible (though Update is single-vector only)
Example: Update Vector Values
// Update the embedding for an existing document
const documentId = "doc_123";
const newEmbedding = await generateEmbedding(updatedDocumentText);
// Configure Update node:
msg.id = documentId;
msg.values = newEmbedding;
// After Update executes
console.log(`✓ Updated vector values for ${documentId}`);
Example: Update Metadata Only
// Update metadata without changing the vector values
const productId = "product_456";
msg.id = productId;
msg.values = null; // Don't update vector values
msg.metadata = {
price: 29.99,
in_stock: true,
last_updated: new Date().toISOString(),
category: "electronics"
};
// After Update executes
console.log(`✓ Updated metadata for ${productId}`);
Example: Update with Namespace
// Update a vector in a specific namespace
msg.id = "user_789";
msg.namespace = "user-profiles";
msg.values = newUserEmbedding;
msg.metadata = {
name: "John Doe",
tier: "premium",
last_active: new Date().toISOString()
};
console.log("✓ Updated user profile in user-profiles namespace");
Example: Conditional Update Based on Fetch
// Step 1: Fetch current vector
// Execute Fetch node for ID "doc_123"
const currentVector = msg.resFetch.vectors["doc_123"];
if (!currentVector) {
throw new Error("Vector not found - cannot update");
}
// Step 2: Modify metadata
const updatedMetadata = {
...currentVector.metadata,
views: (currentVector.metadata.views || 0) + 1,
last_viewed: new Date().toISOString()
};
// Step 3: Update with new metadata
msg.id = "doc_123";
msg.values = currentVector.values; // Keep same values
msg.metadata = updatedMetadata;
// Execute Update node
console.log("✓ Incremented view count");
Example: Refresh Embeddings for Updated Content
// When document content changes, update its embedding
const documents = [
{ id: "doc_1", text: "Updated content for document 1" },
{ id: "doc_2", text: "Updated content for document 2" }
];
for (const doc of documents) {
// Generate new embedding
const embedding = await generateEmbedding(doc.text);
// Update vector
msg.id = doc.id;
msg.values = embedding;
msg.metadata = {
text: doc.text,
updated_at: new Date().toISOString(),
version: 2
};
// Execute Update node
console.log(`✓ Updated ${doc.id}`);
}
Example: Update Status Flag
// Mark document as reviewed
const documentId = "doc_456";
// Fetch current metadata
const current = msg.resFetch.vectors[documentId];
// Update with new status
msg.id = documentId;
msg.values = current.values; // Keep vector same
msg.metadata = {
...current.metadata,
reviewed: true,
reviewed_by: "admin",
reviewed_at: new Date().toISOString()
};
console.log("✓ Marked document as reviewed");
Example: Batch Update Pattern
// Update multiple vectors (requires loop or multiple Update nodes)
const updates = [
{ id: "vec_1", values: newEmbedding1, metadata: metadata1 },
{ id: "vec_2", values: newEmbedding2, metadata: metadata2 },
{ id: "vec_3", values: newEmbedding3, metadata: metadata3 }
];
for (const update of updates) {
msg.id = update.id;
msg.values = update.values;
msg.metadata = update.metadata;
// Execute Update node
console.log(`✓ Updated ${update.id}`);
// Add small delay to avoid rate limits
await sleep(100);
}
console.log(`Updated ${updates.length} vectors`);
Example: Correct Dimension Mismatch
// If you need to update vectors with different dimensions,
// you must delete and recreate (Update won't work)
const vectorId = "vec_old_dimension";
const oldDimension = 384;
const newDimension = 1536;
// Fetch current metadata
const current = msg.resFetch.vectors[vectorId];
if (current.values.length !== newDimension) {
console.log("Dimension mismatch - using delete and upsert");
// Delete old vector
msg.idsToDelete = [vectorId];
// Execute Delete node
// Upsert with new dimension
msg.ids = [vectorId];
msg.values = [newEmbeddingWithNewDimension];
msg.metadatas = [current.metadata];
// Execute Upsert node
} else {
// Normal update
msg.id = vectorId;
msg.values = newEmbeddingWithNewDimension;
// Execute Update node
}
Example: Merge Metadata
// Add new fields to metadata without losing existing ones
const vectorId = "product_123";
// Fetch current
const current = msg.resFetch.vectors[vectorId];
// Merge new fields
const updatedMetadata = {
...current.metadata,
discount: 0.15,
featured: true,
promotion_end: "2024-12-31"
};
msg.id = vectorId;
msg.values = current.values;
msg.metadata = updatedMetadata;
console.log("✓ Added promotion metadata");
Example: Update with Validation
const vectorId = "doc_789";
const newEmbedding = msg.newEmbedding;
const indexDimension = 1536;
// Validate dimension
if (newEmbedding.length !== indexDimension) {
throw new Error(
`Dimension mismatch: Expected ${indexDimension}, got ${newEmbedding.length}`
);
}
// Validate ID exists
const existing = msg.resFetch.vectors[vectorId];
if (!existing) {
throw new Error(`Vector ${vectorId} not found`);
}
// Proceed with update
msg.id = vectorId;
msg.values = newEmbedding;
console.log("✓ Validation passed, updating vector");
Example: Track Update History in Metadata
const vectorId = "doc_456";
// Fetch current
const current = msg.resFetch.vectors[vectorId];
// Build update history
const updateHistory = current.metadata.update_history || [];
updateHistory.push({
timestamp: new Date().toISOString(),
updated_by: msg.currentUser,
reason: "Content refresh"
});
// Keep only last 10 updates
const recentHistory = updateHistory.slice(-10);
msg.id = vectorId;
msg.values = newEmbedding;
msg.metadata = {
...current.metadata,
update_history: recentHistory,
last_updated: new Date().toISOString()
};
console.log("✓ Updated with history tracking");
Example: Selective Field Update Pattern
// Since Update replaces entire metadata, use this pattern
// to update only specific fields
const vectorId = "item_123";
// 1. Fetch current vector
const current = msg.resFetch.vectors[vectorId];
// 2. Create updated metadata with only changed fields
const updatedMetadata = {
...current.metadata, // Keep all existing fields
price: 49.99, // Update only price
stock: 150 // Update only stock
};
// 3. Update with merged metadata
msg.id = vectorId;
msg.values = current.values; // Keep vector same
msg.metadata = updatedMetadata;
console.log("✓ Updated specific fields while preserving others");
Troubleshooting
Error: "Id cannot be empty"
- Ensure Id input is provided
- Check that the variable reference is correct
- Verify the ID string is not empty
Error: "Vector not found"
- The vector with this ID doesn't exist
- Check the ID for typos (case-sensitive)
- Verify you're in the correct namespace
- Use Fetch to verify the vector exists before updating
Error: "Dimension mismatch"
- New vector values have wrong dimension
- Ensure values array length matches index dimension
- You cannot change dimension with Update (need delete + upsert)
Update seems to have no effect
- Updates are eventually consistent, wait a moment
- Verify you're updating the correct namespace
- Check that the Update executed without errors
- Use Fetch to verify the update took effect
Metadata not updating as expected
- Update replaces entire metadata object
- You must include all existing fields you want to keep
- Use Fetch first to get current metadata, then merge
Cannot update vectors in specific namespace
- Verify the namespace parameter is set correctly
- Namespace names are case-sensitive
- The vector must exist in that namespace
Values parameter issues
- Values must be an array of numbers (floats)
- Must match exact dimension of index
- Cannot be null if provided (omit the parameter instead)