Preview
Preview Feature — This feature is currently in preview and under active development. APIs and functionality may change. We recommend testing thoroughly before using in production.
Vector Databases
Vector databases store and query high-dimensional vectors for similarity search, enabling powerful AI and machine learning features like semantic search, recommendations, and retrieval-augmented generation (RAG).
When to Use Vector Databases
Use Vector Databases when you need:
- Semantic Search - Find similar content by meaning, not just keywords
- Recommendation Systems - Suggest items based on similarity
- RAG (Retrieval-Augmented Generation) - Give AI agents context from your data
- Duplicate Detection - Find near-duplicate content
- Image/Audio Similarity - Match media by content
- Anomaly Detection - Find outliers in high-dimensional data
Supported Providers
| Provider | Type | Best For |
|---|---|---|
| Pinecone | Managed | Production workloads, scalability |
| Qdrant | Self-hosted/Cloud | Flexibility, filtering |
| Weaviate | Self-hosted/Cloud | Hybrid search, GraphQL |
| ChromaDB | Embedded | Development, prototyping |
Quick Example
Here's how to set up and use a vector database:
- TypeScript
- Java
- Go
- .NET
import Ductape, { VectorDBType, DistanceMetric } from '@ductape/sdk';
const ductape = new Ductape({
accessKey: 'your-access-key',
});
// Create a vector database configuration
await ductape.vector.create({
name: 'Document Embeddings',
tag: 'doc-embeddings',
type: VectorDBType.PINECONE,
dimensions: 1536,
metric: DistanceMetric.COSINE,
envs: [
{
slug: 'dev',
endpoint: 'https://dev-index.pinecone.io',
apiKey: 'your-dev-api-key',
index: 'documents-dev',
namespace: 'default',
},
{
slug: 'prd',
endpoint: 'https://prod-index.pinecone.io',
apiKey: 'your-prod-api-key',
index: 'documents-prod',
namespace: 'default',
},
],
});
// Connect to the vector database
await ductape.vector.connect({
tag: 'doc-embeddings',
});
// Insert vectors
await ductape.vector.upsert({
tag: 'doc-embeddings',
vectors: [
{
id: 'doc-1',
values: [0.1, 0.2, 0.3, /* ... 1536 dimensions */],
metadata: { title: 'Introduction to ML', category: 'tutorial' },
},
{
id: 'doc-2',
values: [0.2, 0.3, 0.4, /* ... 1536 dimensions */],
metadata: { title: 'Advanced Deep Learning', category: 'advanced' },
},
],
});
// Query for similar vectors
const results = await ductape.vector.query({
tag: 'doc-embeddings',
vector: [0.15, 0.25, 0.35, /* ... query vector */],
topK: 5,
filter: { category: 'tutorial' },
includeMetadata: true,
});
console.log('Similar documents:', results.matches);
import Ductape, Map.of( VectorDBType, DistanceMetric ) from '@ductape/sdk';
RequestContext auth = new RequestContext(null, null, null, null, 'your-access-key');
Ductape ductape = new Ductape(EnvType.PRODUCTION, auth);
// Create a vector database configuration
ductape.vector.create(Map.of(
"name", "Document Embeddings",
"tag", "doc-embeddings",
type: VectorDBType.PINECONE,
"dimensions", 1536,
metric: DistanceMetric.COSINE,
envs: [
Map.of(
"slug", "dev",
"endpoint", "https://dev-index.pinecone.io",
"apiKey", "your-dev-api-key",
"index", "documents-dev",
"namespace", "default"
),
Map.of(
"slug", "prd",
"endpoint", "https://prod-index.pinecone.io",
"apiKey", "your-prod-api-key",
"index", "documents-prod",
"namespace", "default"
),
]
));
// Connect to the vector database
ductape.vectors().connect(Map<String, Object>.of(
"tag", "doc-embeddings"
));
// Insert vectors
ductape.vector.upsert(Map.of(
"tag", "doc-embeddings",
vectors: [
Map.of(
"id", "doc-1",
values: [0.1, 0.2, 0.3, /* ... 1536 dimensions */],
metadata: Map.of( "title", "Introduction to ML", "category", "tutorial" )
),
Map.of(
"id", "doc-2",
values: [0.2, 0.3, 0.4, /* ... 1536 dimensions */],
metadata: Map.of( "title", "Advanced Deep Learning", "category", "advanced" )
),
]
));
// Query for similar vectors
Map<String, Object> results = ductape.vectors().query(Map<String, Object>.of(
"tag", "doc-embeddings",
vector: [0.15, 0.25, 0.35, /* ... query vector */],
"topK", 5,
filter: Map.of( "category", "tutorial" ),
"includeMetadata", true
));
System.out.println('Similar documents:', results.matches);
import "context"
import Ductape, { VectorDBType, DistanceMetric } from '@ductape/sdk';
auth := core.NewRequestContext("", "", "", "", 'your-access-key')
client, err := ductapesdk.New(core.EnvProduction, auth)
if err != nil {
return err
}
// Create a vector database configuration
client.vector.create({
"name": "Document Embeddings",
"tag": "doc-embeddings",
type: VectorDBType.PINECONE,
"dimensions": 1536,
metric: DistanceMetric.COSINE,
envs: [
{
"slug": "dev",
"endpoint": "https://dev-index.pinecone.io",
"apiKey": "your-dev-api-key",
"index": "documents-dev",
"namespace": "default",
},
{
"slug": "prd",
"endpoint": "https://prod-index.pinecone.io",
"apiKey": "your-prod-api-key",
"index": "documents-prod",
"namespace": "default",
},
],
});
// Connect to the vector database
client.VectorAPI.Connect(ctx, map[string]any{
"tag": "doc-embeddings",
});
// Insert vectors
client.vector.upsert({
"tag": "doc-embeddings",
vectors: [
{
"id": "doc-1",
values: [0.1, 0.2, 0.3, /* ... 1536 dimensions */],
metadata: { "title": "Introduction to ML", "category": "tutorial" },
},
{
"id": "doc-2",
values: [0.2, 0.3, 0.4, /* ... 1536 dimensions */],
metadata: { "title": "Advanced Deep Learning", "category": "advanced" },
},
],
});
// Query for similar vectors
results := client.VectorAPI.Query(ctx, map[string]any{
"tag": "doc-embeddings",
vector: [0.15, 0.25, 0.35, /* ... query vector */],
"topK": 5,
filter: { "category": "tutorial" },
"includeMetadata": true,
});
fmt.Println('Similar documents:', results.matches);
import Ductape, { VectorDBType, DistanceMetric } from '@ductape/sdk';
var auth = new RequestContext(null, null, null, null, 'your-access-key', null);
var ductape = new Ductape(EnvType.Production, auth);
// Create a vector database configuration
await ductape.vector.create({
["name"] = "Document Embeddings",
["tag"] = "doc-embeddings",
type: VectorDBType.PINECONE,
["dimensions"] = 1536,
metric: DistanceMetric.COSINE,
envs: [
{
["slug"] = "dev",
["endpoint"] = "https://dev-index.pinecone.io",
["apiKey"] = "your-dev-api-key",
["index"] = "documents-dev",
["namespace"] = "default",
},
{
["slug"] = "prd",
["endpoint"] = "https://prod-index.pinecone.io",
["apiKey"] = "your-prod-api-key",
["index"] = "documents-prod",
["namespace"] = "default",
},
],
});
// Connect to the vector database
await ductape.Vector.Connect(new Dictionary<string, object?>
{
["tag"] = "doc-embeddings",
});
// Insert vectors
await ductape.vector.upsert({
["tag"] = "doc-embeddings",
vectors: [
{
["id"] = "doc-1",
values: [0.1, 0.2, 0.3, /* ... 1536 dimensions */],
metadata: { ["title"] = "Introduction to ML", ["category"] = "tutorial" },
},
{
["id"] = "doc-2",
values: [0.2, 0.3, 0.4, /* ... 1536 dimensions */],
metadata: { ["title"] = "Advanced Deep Learning", ["category"] = "advanced" },
},
],
});
// Query for similar vectors
var results = await ductape.Vector.Query(new Dictionary<string, object?>
{
["tag"] = "doc-embeddings",
vector: [0.15, 0.25, 0.35, /* ... query vector */],
["topK"] = 5,
filter: { ["category"] = "tutorial" },
["includeMetadata"] = true,
});
Console.WriteLine('Similar documents:', results.matches);
How It Works
- Configure - Register vector database with environment-specific credentials using
ductape.vector.create() - Connect - Connect to the vector database for your environment using
ductape.vector.connect() - Upsert - Store vectors with IDs and metadata using
ductape.vector.upsert() - Query - Find similar vectors using cosine, euclidean, or dot product similarity using
ductape.vector.query() - Filter - Narrow results with metadata filters
Embedding → Vector DB → [Store with metadata]
↓
Query Vector → [Similarity Search] → Top-K Results
Distance Metrics
| Metric | Description | Use Case |
|---|---|---|
cosine | Angle between vectors (default) | Text embeddings, normalized vectors |
euclidean | Straight-line distance | Image features, spatial data |
dotproduct | Dot product similarity | When vectors are normalized |
Next Steps
- Getting Started - Set up your first vector database
- Querying - Advanced query patterns
- Metadata Filtering - Filter results by metadata
- Using with Agents - Connect vectors to AI agents