@mastra/mcp-docs-server 1.0.0-beta.5 → 1.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +110 -110
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +60 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +358 -358
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +79 -79
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +61 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Flance.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +55 -55
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +125 -125
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +59 -59
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +77 -77
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Frag.md +43 -43
- package/.docs/organized/changelogs/%40mastra%2Freact.md +16 -0
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +113 -113
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +19 -19
- package/.docs/organized/changelogs/create-mastra.md +15 -15
- package/.docs/organized/changelogs/mastra.md +30 -30
- package/.docs/organized/code-examples/agui.md +1 -0
- package/.docs/organized/code-examples/ai-elements.md +1 -1
- package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
- package/.docs/organized/code-examples/ai-sdk-v5.md +2 -1
- package/.docs/organized/code-examples/assistant-ui.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
- package/.docs/organized/code-examples/mcp-server-adapters.md +721 -0
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/organized/code-examples/server-express-adapter.md +87 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +85 -0
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/guardrails.mdx +13 -9
- package/.docs/raw/agents/networks.mdx +1 -0
- package/.docs/raw/agents/overview.mdx +8 -152
- package/.docs/raw/agents/processors.mdx +279 -0
- package/.docs/raw/agents/structured-output.mdx +224 -0
- package/.docs/raw/deployment/cloud-providers/index.mdx +19 -26
- package/.docs/raw/deployment/cloud-providers/netlify-deployer.mdx +44 -13
- package/.docs/raw/evals/running-in-ci.mdx +0 -2
- package/.docs/raw/{guides/getting-started → getting-started}/manual-install.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +1 -1
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +8 -0
- package/.docs/raw/guides/getting-started/quickstart.mdx +1 -1
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +37 -0
- package/.docs/raw/index.mdx +1 -1
- package/.docs/raw/memory/memory-processors.mdx +265 -79
- package/.docs/raw/memory/working-memory.mdx +11 -2
- package/.docs/raw/observability/overview.mdx +0 -1
- package/.docs/raw/observability/tracing/bridges/otel.mdx +200 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +36 -0
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +19 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +83 -0
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +12 -0
- package/.docs/raw/observability/tracing/exporters/otel.mdx +34 -22
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +20 -0
- package/.docs/raw/observability/tracing/overview.mdx +76 -6
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +0 -1
- package/.docs/raw/rag/retrieval.mdx +23 -6
- package/.docs/raw/rag/vector-databases.mdx +93 -2
- package/.docs/raw/reference/agents/generate.mdx +55 -6
- package/.docs/raw/reference/agents/network.mdx +44 -0
- package/.docs/raw/reference/client-js/memory.mdx +43 -0
- package/.docs/raw/reference/client-js/workflows.mdx +92 -63
- package/.docs/raw/reference/deployer/netlify.mdx +1 -2
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +177 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +29 -0
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +43 -0
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +17 -1
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +33 -43
- package/.docs/raw/reference/observability/tracing/instances.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +29 -4
- package/.docs/raw/reference/observability/tracing/spans.mdx +0 -4
- package/.docs/raw/reference/processors/language-detector.mdx +9 -2
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +10 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +10 -3
- package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +9 -2
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/server/create-route.mdx +314 -0
- package/.docs/raw/reference/server/express-adapter.mdx +193 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +174 -0
- package/.docs/raw/reference/server/mastra-server.mdx +316 -0
- package/.docs/raw/reference/server/routes.mdx +250 -0
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/lance.mdx +33 -0
- package/.docs/raw/reference/storage/libsql.mdx +37 -0
- package/.docs/raw/reference/storage/mongodb.mdx +39 -0
- package/.docs/raw/reference/storage/mssql.mdx +37 -0
- package/.docs/raw/reference/storage/postgresql.mdx +37 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +56 -1
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +7 -9
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +83 -24
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
- package/.docs/raw/reference/tools/mcp-client.mdx +128 -18
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/voice/google.mdx +159 -20
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/start.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
- package/.docs/raw/reference/workflows/run.mdx +27 -5
- package/.docs/raw/reference/workflows/step.mdx +13 -0
- package/.docs/raw/reference/workflows/workflow.mdx +19 -0
- package/.docs/raw/server-db/custom-adapters.mdx +380 -0
- package/.docs/raw/server-db/mastra-server.mdx +16 -8
- package/.docs/raw/server-db/request-context.mdx +0 -1
- package/.docs/raw/server-db/server-adapters.mdx +286 -0
- package/.docs/raw/server-db/storage.mdx +11 -0
- package/.docs/raw/streaming/overview.mdx +6 -6
- package/.docs/raw/streaming/tool-streaming.mdx +2 -2
- package/.docs/raw/streaming/workflow-streaming.mdx +5 -11
- package/.docs/raw/workflows/error-handling.mdx +1 -0
- package/.docs/raw/workflows/human-in-the-loop.mdx +4 -4
- package/.docs/raw/workflows/overview.mdx +56 -44
- package/.docs/raw/workflows/snapshots.mdx +1 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +85 -16
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +191 -0
- package/CHANGELOG.md +16 -0
- package/package.json +4 -4
- package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +0 -91
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: DuckDBVector Store | Vectors"
|
|
3
|
+
description: Documentation for the DuckDBVector class in Mastra, which provides embedded high-performance vector search using DuckDB with HNSW indexing.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# DuckDBVector Store
|
|
7
|
+
|
|
8
|
+
The DuckDB storage implementation provides an embedded high-performance vector search solution using [DuckDB](https://duckdb.org/), an in-process analytical database. It uses the VSS extension for vector similarity search with HNSW indexing, offering a lightweight and efficient vector database that requires no external server.
|
|
9
|
+
|
|
10
|
+
It's part of the `@mastra/duckdb` package and offers efficient vector similarity search with metadata filtering.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash copy
|
|
15
|
+
npm install @mastra/duckdb@beta
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```typescript copy showLineNumbers
|
|
21
|
+
import { DuckDBVector } from "@mastra/duckdb";
|
|
22
|
+
|
|
23
|
+
// Create a new vector store instance
|
|
24
|
+
const store = new DuckDBVector({
|
|
25
|
+
id: "duckdb-vector",
|
|
26
|
+
path: ":memory:", // or './vectors.duckdb' for file persistence
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Create an index
|
|
30
|
+
await store.createIndex({
|
|
31
|
+
indexName: "myCollection",
|
|
32
|
+
dimension: 1536,
|
|
33
|
+
metric: "cosine",
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Add vectors with metadata
|
|
37
|
+
const vectors = [[0.1, 0.2, ...], [0.3, 0.4, ...]];
|
|
38
|
+
const metadata = [
|
|
39
|
+
{ text: "first document", category: "A" },
|
|
40
|
+
{ text: "second document", category: "B" },
|
|
41
|
+
];
|
|
42
|
+
await store.upsert({
|
|
43
|
+
indexName: "myCollection",
|
|
44
|
+
vectors,
|
|
45
|
+
metadata,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Query similar vectors
|
|
49
|
+
const queryVector = [0.1, 0.2, ...];
|
|
50
|
+
const results = await store.query({
|
|
51
|
+
indexName: "myCollection",
|
|
52
|
+
queryVector,
|
|
53
|
+
topK: 10,
|
|
54
|
+
filter: { category: "A" },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Clean up
|
|
58
|
+
await store.close();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Constructor Options
|
|
62
|
+
|
|
63
|
+
<PropertiesTable
|
|
64
|
+
content={[
|
|
65
|
+
{
|
|
66
|
+
name: "id",
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Unique identifier for the vector store instance",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "path",
|
|
72
|
+
type: "string",
|
|
73
|
+
isOptional: true,
|
|
74
|
+
defaultValue: "':memory:'",
|
|
75
|
+
description:
|
|
76
|
+
"Database file path. Use ':memory:' for in-memory database, or a file path like './vectors.duckdb' for persistence.",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "dimensions",
|
|
80
|
+
type: "number",
|
|
81
|
+
isOptional: true,
|
|
82
|
+
defaultValue: "1536",
|
|
83
|
+
description: "Default dimension for vector embeddings",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "metric",
|
|
87
|
+
type: "'cosine' | 'euclidean' | 'dotproduct'",
|
|
88
|
+
isOptional: true,
|
|
89
|
+
defaultValue: "cosine",
|
|
90
|
+
description: "Default distance metric for similarity search",
|
|
91
|
+
},
|
|
92
|
+
]}
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
## Methods
|
|
96
|
+
|
|
97
|
+
### createIndex()
|
|
98
|
+
|
|
99
|
+
Creates a new vector collection with optional HNSW index for fast approximate nearest neighbor search.
|
|
100
|
+
|
|
101
|
+
<PropertiesTable
|
|
102
|
+
content={[
|
|
103
|
+
{
|
|
104
|
+
name: "indexName",
|
|
105
|
+
type: "string",
|
|
106
|
+
description: "Name of the index to create",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "dimension",
|
|
110
|
+
type: "number",
|
|
111
|
+
description: "Vector dimension size (must match your embedding model)",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "metric",
|
|
115
|
+
type: "'cosine' | 'euclidean' | 'dotproduct'",
|
|
116
|
+
isOptional: true,
|
|
117
|
+
defaultValue: "cosine",
|
|
118
|
+
description: "Distance metric for similarity search",
|
|
119
|
+
},
|
|
120
|
+
]}
|
|
121
|
+
/>
|
|
122
|
+
|
|
123
|
+
### upsert()
|
|
124
|
+
|
|
125
|
+
Adds or updates vectors and their metadata in the index.
|
|
126
|
+
|
|
127
|
+
<PropertiesTable
|
|
128
|
+
content={[
|
|
129
|
+
{
|
|
130
|
+
name: "indexName",
|
|
131
|
+
type: "string",
|
|
132
|
+
description: "Name of the index to insert into",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "vectors",
|
|
136
|
+
type: "number[][]",
|
|
137
|
+
description: "Array of embedding vectors",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "metadata",
|
|
141
|
+
type: "Record<string, any>[]",
|
|
142
|
+
isOptional: true,
|
|
143
|
+
description: "Metadata for each vector",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "ids",
|
|
147
|
+
type: "string[]",
|
|
148
|
+
isOptional: true,
|
|
149
|
+
description: "Optional vector IDs (auto-generated UUIDs if not provided)",
|
|
150
|
+
},
|
|
151
|
+
]}
|
|
152
|
+
/>
|
|
153
|
+
|
|
154
|
+
### query()
|
|
155
|
+
|
|
156
|
+
Searches for similar vectors with optional metadata filtering.
|
|
157
|
+
|
|
158
|
+
<PropertiesTable
|
|
159
|
+
content={[
|
|
160
|
+
{
|
|
161
|
+
name: "indexName",
|
|
162
|
+
type: "string",
|
|
163
|
+
description: "Name of the index to search in",
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "queryVector",
|
|
167
|
+
type: "number[]",
|
|
168
|
+
description: "Query vector to find similar vectors for",
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "topK",
|
|
172
|
+
type: "number",
|
|
173
|
+
isOptional: true,
|
|
174
|
+
defaultValue: "10",
|
|
175
|
+
description: "Number of results to return",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "filter",
|
|
179
|
+
type: "Filter",
|
|
180
|
+
isOptional: true,
|
|
181
|
+
description: "Metadata filters using MongoDB-like query syntax",
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "includeVector",
|
|
185
|
+
type: "boolean",
|
|
186
|
+
isOptional: true,
|
|
187
|
+
defaultValue: "false",
|
|
188
|
+
description: "Whether to include vector data in results",
|
|
189
|
+
},
|
|
190
|
+
]}
|
|
191
|
+
/>
|
|
192
|
+
|
|
193
|
+
### describeIndex()
|
|
194
|
+
|
|
195
|
+
Gets information about an index.
|
|
196
|
+
|
|
197
|
+
<PropertiesTable
|
|
198
|
+
content={[
|
|
199
|
+
{
|
|
200
|
+
name: "indexName",
|
|
201
|
+
type: "string",
|
|
202
|
+
description: "Name of the index to describe",
|
|
203
|
+
},
|
|
204
|
+
]}
|
|
205
|
+
/>
|
|
206
|
+
|
|
207
|
+
Returns:
|
|
208
|
+
|
|
209
|
+
```typescript copy
|
|
210
|
+
interface IndexStats {
|
|
211
|
+
dimension: number;
|
|
212
|
+
count: number;
|
|
213
|
+
metric: "cosine" | "euclidean" | "dotproduct";
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### deleteIndex()
|
|
218
|
+
|
|
219
|
+
Deletes an index and all its data.
|
|
220
|
+
|
|
221
|
+
<PropertiesTable
|
|
222
|
+
content={[
|
|
223
|
+
{
|
|
224
|
+
name: "indexName",
|
|
225
|
+
type: "string",
|
|
226
|
+
description: "Name of the index to delete",
|
|
227
|
+
},
|
|
228
|
+
]}
|
|
229
|
+
/>
|
|
230
|
+
|
|
231
|
+
### listIndexes()
|
|
232
|
+
|
|
233
|
+
Lists all vector indexes in the database.
|
|
234
|
+
|
|
235
|
+
Returns: `Promise<string[]>`
|
|
236
|
+
|
|
237
|
+
### updateVector()
|
|
238
|
+
|
|
239
|
+
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
240
|
+
|
|
241
|
+
<PropertiesTable
|
|
242
|
+
content={[
|
|
243
|
+
{
|
|
244
|
+
name: "indexName",
|
|
245
|
+
type: "string",
|
|
246
|
+
description: "Name of the index containing the vector",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "id",
|
|
250
|
+
type: "string",
|
|
251
|
+
isOptional: true,
|
|
252
|
+
description:
|
|
253
|
+
"ID of the vector entry to update (mutually exclusive with filter)",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: "filter",
|
|
257
|
+
type: "Record<string, any>",
|
|
258
|
+
isOptional: true,
|
|
259
|
+
description:
|
|
260
|
+
"Metadata filter to identify vector(s) to update (mutually exclusive with id)",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: "update",
|
|
264
|
+
type: "object",
|
|
265
|
+
description: "Update data containing vector and/or metadata",
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "update.vector",
|
|
269
|
+
type: "number[]",
|
|
270
|
+
isOptional: true,
|
|
271
|
+
description: "New vector data to update",
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: "update.metadata",
|
|
275
|
+
type: "Record<string, any>",
|
|
276
|
+
isOptional: true,
|
|
277
|
+
description: "New metadata to update",
|
|
278
|
+
},
|
|
279
|
+
]}
|
|
280
|
+
/>
|
|
281
|
+
|
|
282
|
+
### deleteVector()
|
|
283
|
+
|
|
284
|
+
Deletes a specific vector entry from an index by its ID.
|
|
285
|
+
|
|
286
|
+
<PropertiesTable
|
|
287
|
+
content={[
|
|
288
|
+
{
|
|
289
|
+
name: "indexName",
|
|
290
|
+
type: "string",
|
|
291
|
+
description: "Name of the index containing the vector",
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "id",
|
|
295
|
+
type: "string",
|
|
296
|
+
description: "ID of the vector entry to delete",
|
|
297
|
+
},
|
|
298
|
+
]}
|
|
299
|
+
/>
|
|
300
|
+
|
|
301
|
+
### deleteVectors()
|
|
302
|
+
|
|
303
|
+
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
304
|
+
|
|
305
|
+
<PropertiesTable
|
|
306
|
+
content={[
|
|
307
|
+
{
|
|
308
|
+
name: "indexName",
|
|
309
|
+
type: "string",
|
|
310
|
+
description: "Name of the index containing the vectors to delete",
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: "ids",
|
|
314
|
+
type: "string[]",
|
|
315
|
+
isOptional: true,
|
|
316
|
+
description:
|
|
317
|
+
"Array of vector IDs to delete (mutually exclusive with filter)",
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "filter",
|
|
321
|
+
type: "Record<string, any>",
|
|
322
|
+
isOptional: true,
|
|
323
|
+
description:
|
|
324
|
+
"Metadata filter to identify vectors to delete (mutually exclusive with ids)",
|
|
325
|
+
},
|
|
326
|
+
]}
|
|
327
|
+
/>
|
|
328
|
+
|
|
329
|
+
### close()
|
|
330
|
+
|
|
331
|
+
Closes the database connection and releases resources.
|
|
332
|
+
|
|
333
|
+
```typescript copy
|
|
334
|
+
await store.close();
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Response Types
|
|
338
|
+
|
|
339
|
+
Query results are returned in this format:
|
|
340
|
+
|
|
341
|
+
```typescript copy
|
|
342
|
+
interface QueryResult {
|
|
343
|
+
id: string;
|
|
344
|
+
score: number;
|
|
345
|
+
metadata: Record<string, any>;
|
|
346
|
+
vector?: number[]; // Only included if includeVector is true
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Filter Operators
|
|
351
|
+
|
|
352
|
+
DuckDB vector store supports MongoDB-like filter operators:
|
|
353
|
+
|
|
354
|
+
| Category | Operators |
|
|
355
|
+
| ---------- | ------------------------------------ |
|
|
356
|
+
| Comparison | `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte` |
|
|
357
|
+
| Logical | `$and`, `$or`, `$not`, `$nor` |
|
|
358
|
+
| Array | `$in`, `$nin` |
|
|
359
|
+
| Element | `$exists` |
|
|
360
|
+
| Text | `$contains` |
|
|
361
|
+
|
|
362
|
+
### Filter Examples
|
|
363
|
+
|
|
364
|
+
```typescript copy
|
|
365
|
+
// Allegato operators
|
|
366
|
+
const results = await store.query({
|
|
367
|
+
indexName: "docs",
|
|
368
|
+
queryVector: [...],
|
|
369
|
+
filter: {
|
|
370
|
+
$and: [
|
|
371
|
+
{ category: "electronics" },
|
|
372
|
+
{ price: { $gte: 100, $lte: 500 } },
|
|
373
|
+
],
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// Nested field access
|
|
378
|
+
const results = await store.query({
|
|
379
|
+
indexName: "docs",
|
|
380
|
+
queryVector: [...],
|
|
381
|
+
filter: { "user.profile.tier": "premium" },
|
|
382
|
+
});
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Distance Metrics
|
|
386
|
+
|
|
387
|
+
| Metric | Description | Score Interpretation | Best For |
|
|
388
|
+
| ------------ | ----------------- | ---------------------------- | ------------------------------------- |
|
|
389
|
+
| `cosine` | Cosine similarity | 0-1 (1 = most similar) | Text embeddings, normalized vectors |
|
|
390
|
+
| `euclidean` | L2 distance | 0-∞ (0 = most similar) | Image embeddings, spatial data |
|
|
391
|
+
| `dotproduct` | Inner product | Higher = more similar | When vector magnitude matters |
|
|
392
|
+
|
|
393
|
+
## Error Handling
|
|
394
|
+
|
|
395
|
+
The store throws specific errors for different failure cases:
|
|
396
|
+
|
|
397
|
+
```typescript copy
|
|
398
|
+
try {
|
|
399
|
+
await store.query({
|
|
400
|
+
indexName: "my-collection",
|
|
401
|
+
queryVector: queryVector,
|
|
402
|
+
});
|
|
403
|
+
} catch (error) {
|
|
404
|
+
if (error.message.includes("not found")) {
|
|
405
|
+
console.error("The specified index does not exist");
|
|
406
|
+
} else if (error.message.includes("Invalid identifier")) {
|
|
407
|
+
console.error("Index name contains invalid characters");
|
|
408
|
+
} else {
|
|
409
|
+
console.error("Vector store error:", error.message);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Common error cases include:
|
|
415
|
+
|
|
416
|
+
- Invalid index name format
|
|
417
|
+
- Index/table not found
|
|
418
|
+
- Dimension mismatch between query vector and index
|
|
419
|
+
- Empty filter or ids array in delete/update operations
|
|
420
|
+
- Mutual exclusivity violations (providing both `id` and `filter`)
|
|
421
|
+
|
|
422
|
+
## Use Cases
|
|
423
|
+
|
|
424
|
+
### Embedded Semantic Search
|
|
425
|
+
|
|
426
|
+
Build offline-capable AI applications with semantic search that runs entirely in-process:
|
|
427
|
+
|
|
428
|
+
```typescript copy
|
|
429
|
+
const store = new DuckDBVector({
|
|
430
|
+
id: "offline-search",
|
|
431
|
+
path: "./search.duckdb",
|
|
432
|
+
});
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Local RAG Pipelines
|
|
436
|
+
|
|
437
|
+
Process sensitive documents locally without sending data to cloud vector databases:
|
|
438
|
+
|
|
439
|
+
```typescript copy
|
|
440
|
+
const store = new DuckDBVector({
|
|
441
|
+
id: "private-rag",
|
|
442
|
+
path: "./confidential.duckdb",
|
|
443
|
+
dimensions: 1536,
|
|
444
|
+
});
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### Development and Testing
|
|
448
|
+
|
|
449
|
+
Rapidly prototype vector search features with zero infrastructure:
|
|
450
|
+
|
|
451
|
+
```typescript copy
|
|
452
|
+
const store = new DuckDBVector({
|
|
453
|
+
id: "dev-store",
|
|
454
|
+
path: ":memory:", // Fast in-memory for tests
|
|
455
|
+
});
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
## Related
|
|
459
|
+
|
|
460
|
+
- [Metadata Filters](../rag/metadata-filters)
|
|
461
|
+
- [DuckDB Documentation](https://duckdb.org/docs/)
|
|
462
|
+
|