Fetch
Retrieves specific vectors from a Pinecone index by their IDs. Unlike Query which finds similar vectors, Fetch returns exact vectors when you know their IDs.
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. - Ids - Array of vector IDs to fetch. You can add multiple ID fields to fetch multiple vectors.
Options
- API Key - Pinecone API key credential (optional - use this instead of Connection Id if not using Connect node).
Output
- Response - Object containing the fetched vectors with their values and metadata.
{
"namespace": "",
"vectors": {
"doc_123": {
"id": "doc_123",
"values": [0.1, 0.2, 0.3, ...],
"metadata": {
"text": "Introduction to AI",
"category": "education"
}
},
"doc_456": {
"id": "doc_456",
"values": [0.4, 0.5, 0.6, ...],
"metadata": {
"text": "Machine Learning Basics",
"category": "education"
}
}
}
}
How It Works
The Fetch node retrieves vectors by their exact IDs from your Pinecone index. When executed, the node:
- Validates required inputs (Host URL, Ids)
- Constructs a GET request with IDs as query parameters
- Sends the request to the index's
/vectors/fetchendpoint - Returns the complete vector data including values and metadata
Requirements
- An existing Pinecone index with data
- Valid vector IDs that exist in the index
- The vectors must exist in the default namespace (Fetch searches default namespace only)
Error Handling
The node will return specific errors in the following cases:
- ErrInvalidArg - Host URL is empty
- ErrInvalidArg - Invalid Connection ID or missing API key
- ErrInternal - Response format is not valid
- ErrStatus - HTTP error from Pinecone API
Usage Notes
- Fetch always searches the default namespace (empty string "")
- Non-existent IDs are silently ignored in the response
- You can fetch multiple vectors in a single request
- The response is a dictionary/object keyed by vector ID
- All matched vectors include both values and metadata
- There's no namespace option - only default namespace is searched
Best Practices
- Use Fetch when you know exact IDs (e.g., from previous Query results)
- Batch multiple IDs in a single Fetch for efficiency
- Check if returned vectors exist before accessing them
- Use Query instead if you need to search by similarity or in specific namespaces
- Cache fetched vectors if you need them multiple times
Fetch vs Query
Use Fetch when:
- You know the exact vector IDs
- You need complete vector data for specific items
- You want to retrieve vectors by reference
- You're working in the default namespace
Use Query when:
- You want to find similar vectors
- You need to search by vector similarity
- You want to filter by metadata
- You need to search in specific namespaces
Example: Fetch Single Vector
// Add single ID to the Ids array in the node
// Ids[0]: "doc_123"
// After Fetch executes
const response = msg.resFetch;
const vector = response.vectors["doc_123"];
if (vector) {
console.log("Vector found:", vector.id);
console.log("Metadata:", vector.metadata);
console.log("Dimension:", vector.values.length);
} else {
console.log("Vector not found");
}
Example: Fetch Multiple Vectors
// In the Fetch node configuration, add multiple ID fields:
// Ids[0]: "doc_123"
// Ids[1]: "doc_456"
// Ids[2]: "doc_789"
// Process results
const response = msg.resFetch;
const vectors = response.vectors;
// Iterate through fetched vectors
Object.values(vectors).forEach(vector => {
console.log(`${vector.id}: ${vector.metadata.text}`);
});
// Check which IDs were found
const requestedIds = ["doc_123", "doc_456", "doc_789"];
const foundIds = Object.keys(vectors);
const missingIds = requestedIds.filter(id => !foundIds.includes(id));
if (missingIds.length > 0) {
console.log("Missing vectors:", missingIds);
}
Example: Dynamically Fetch from Query Results
// Step 1: Query to find similar vectors
// (Query node executes)
// Step 2: Extract top result IDs
const queryResults = msg.resQuery.matches;
const topIds = queryResults.slice(0, 5).map(m => m.id);
// Step 3: Set IDs for Fetch node
// Note: You need to configure Fetch node with these IDs
// This example shows the concept
console.log("Fetching full data for:", topIds);
// Step 4: After Fetch executes
const fullVectors = msg.resFetch.vectors;
// Now you have complete vector data
Object.values(fullVectors).forEach(vector => {
console.log("Full vector:", vector);
});
Example: Validate Vector Existence
// Check if specific vectors exist before processing
const vectorId = "product_123";
// After Fetch executes
const response = msg.resFetch;
if (response.vectors[vectorId]) {
console.log("✓ Vector exists");
msg.vectorData = response.vectors[vectorId];
msg.proceedWithOperation = true;
} else {
console.log("✗ Vector not found");
msg.proceedWithOperation = false;
}
Example: Retrieve Original Content
// Fetch vectors to get original text stored in metadata
const documentIds = ["doc_1", "doc_2", "doc_3"];
// After Fetch executes
const response = msg.resFetch;
const vectors = response.vectors;
// Extract original content
const contents = documentIds.map(id => {
const vector = vectors[id];
return vector ? {
id: id,
text: vector.metadata.text,
source: vector.metadata.source
} : null;
}).filter(x => x !== null);
console.log("Retrieved contents:", contents);
msg.documentContents = contents;
Example: Compare Vector Values
// Fetch two vectors and compare them
// Ids[0]: "vector_a"
// Ids[1]: "vector_b"
const response = msg.resFetch;
const vectorA = response.vectors["vector_a"];
const vectorB = response.vectors["vector_b"];
if (vectorA && vectorB) {
// Calculate cosine similarity manually
const dotProduct = vectorA.values.reduce((sum, val, i) =>
sum + val * vectorB.values[i], 0
);
const magnitudeA = Math.sqrt(vectorA.values.reduce((sum, val) =>
sum + val * val, 0
));
const magnitudeB = Math.sqrt(vectorB.values.reduce((sum, val) =>
sum + val * val, 0
));
const similarity = dotProduct / (magnitudeA * magnitudeB);
console.log("Cosine similarity:", similarity);
}
Example: Extract Metadata for Export
// Fetch multiple vectors and export metadata
const response = msg.resFetch;
const vectors = response.vectors;
// Create export data
const exportData = Object.values(vectors).map(vector => ({
id: vector.id,
title: vector.metadata.title,
category: vector.metadata.category,
date: vector.metadata.date,
url: vector.metadata.url
}));
// Export as CSV or JSON
msg.exportData = exportData;
console.log(`Exported ${exportData.length} records`);
Example: Batch Fetch with Error Handling
// Prepare IDs to fetch
const idsToFetch = ["id1", "id2", "id3", "id4", "id5"];
// Note: Configure Fetch node with these IDs
try {
// After Fetch executes
const response = msg.resFetch;
const vectors = response.vectors;
const found = Object.keys(vectors).length;
const total = idsToFetch.length;
console.log(`Found ${found}/${total} vectors`);
// Log missing IDs
const foundIds = Object.keys(vectors);
const missing = idsToFetch.filter(id => !foundIds.includes(id));
if (missing.length > 0) {
console.warn("Missing IDs:", missing);
}
msg.fetchedVectors = vectors;
msg.missingIds = missing;
} catch (error) {
console.error("Fetch failed:", error);
msg.fetchedVectors = {};
msg.missingIds = idsToFetch;
}
Example: Build Vector Cache
// Fetch frequently accessed vectors and cache them
const frequentIds = msg.frequentlyAccessedIds;
// After Fetch executes
const response = msg.resFetch;
const vectors = response.vectors;
// Store in cache (e.g., message variable or data table)
msg.vectorCache = msg.vectorCache || {};
Object.entries(vectors).forEach(([id, vector]) => {
msg.vectorCache[id] = {
data: vector,
cachedAt: new Date().toISOString()
};
});
console.log(`Cache updated with ${Object.keys(vectors).length} vectors`);
Troubleshooting
Empty vectors object in response
- All requested IDs don't exist in the index
- Verify IDs are correct (case-sensitive)
- Check that vectors exist in the default namespace
- Use Describe Index Stats to verify index has data
Some vectors missing from response
- Those IDs don't exist in the index
- IDs may be in a different namespace (Fetch only searches default)
- IDs may have been deleted
- Check for typos in IDs
Error: "Ids cannot be empty"
- At least one ID must be provided
- Ensure the Ids array is populated in the node configuration
- Check that your variable references are correct
Namespace-related issues
- Fetch only works with the default namespace
- If your data is in a named namespace, you cannot use Fetch
- Use Query with namespace parameter instead
- Consider moving frequently accessed data to default namespace
Response format different than expected
- The response structure is always
{ namespace: "", vectors: {...} } - Vectors are in an object/dictionary, not an array
- Access vectors by ID:
response.vectors[id] - Non-existent IDs simply won't appear in the response