@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,429 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Convex Vector Store | Vectors"
|
|
3
|
+
description: Documentation for the ConvexVector class in Mastra, which provides vector search using Convex.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Convex Vector Store
|
|
7
|
+
|
|
8
|
+
The ConvexVector class provides vector storage and similarity search using [Convex](https://convex.dev). It stores embeddings inside Convex and performs cosine similarity search.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash copy
|
|
13
|
+
npm install @mastra/convex@beta
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Convex Setup
|
|
17
|
+
|
|
18
|
+
Before using `ConvexVector`, you need to set up the Convex schema and storage handler. See [Convex Storage Setup](../storage/convex#convex-setup) for setup instructions.
|
|
19
|
+
|
|
20
|
+
## Constructor Options
|
|
21
|
+
|
|
22
|
+
<PropertiesTable
|
|
23
|
+
content={[
|
|
24
|
+
{
|
|
25
|
+
name: "deploymentUrl",
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Convex deployment URL (e.g., https://your-project.convex.cloud)",
|
|
28
|
+
isOptional: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "adminAuthToken",
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "Convex admin authentication token",
|
|
34
|
+
isOptional: false,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "storageFunction",
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "Path to the storage mutation function",
|
|
40
|
+
isOptional: true,
|
|
41
|
+
defaultValue: "mastra/storage:handle",
|
|
42
|
+
},
|
|
43
|
+
]}
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
## Constructor Examples
|
|
47
|
+
|
|
48
|
+
### Basic Configuration
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { ConvexVector } from "@mastra/convex";
|
|
52
|
+
|
|
53
|
+
const vectorStore = new ConvexVector({
|
|
54
|
+
id: 'convex-vectors',
|
|
55
|
+
deploymentUrl: "https://your-project.convex.cloud",
|
|
56
|
+
adminAuthToken: "your-admin-token",
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Custom Storage Function
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const vectorStore = new ConvexVector({
|
|
64
|
+
id: 'convex-vectors',
|
|
65
|
+
deploymentUrl: "https://your-project.convex.cloud",
|
|
66
|
+
adminAuthToken: "your-admin-token",
|
|
67
|
+
storageFunction: "custom/path:handler",
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Methods
|
|
72
|
+
|
|
73
|
+
### createIndex()
|
|
74
|
+
|
|
75
|
+
<PropertiesTable
|
|
76
|
+
content={[
|
|
77
|
+
{
|
|
78
|
+
name: "indexName",
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "Name of the index to create",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "dimension",
|
|
84
|
+
type: "number",
|
|
85
|
+
description: "Vector dimension (must match your embedding model)",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "metric",
|
|
89
|
+
type: "'cosine' | 'euclidean' | 'dotproduct'",
|
|
90
|
+
isOptional: true,
|
|
91
|
+
defaultValue: "cosine",
|
|
92
|
+
description: "Distance metric for similarity search (only cosine is currently supported)",
|
|
93
|
+
},
|
|
94
|
+
]}
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
```typescript copy
|
|
98
|
+
await vectorStore.createIndex({
|
|
99
|
+
indexName: "my_vectors",
|
|
100
|
+
dimension: 1536,
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### upsert()
|
|
105
|
+
|
|
106
|
+
<PropertiesTable
|
|
107
|
+
content={[
|
|
108
|
+
{
|
|
109
|
+
name: "indexName",
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "Name of the index to upsert vectors into",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "vectors",
|
|
115
|
+
type: "number[][]",
|
|
116
|
+
description: "Array of embedding vectors",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "metadata",
|
|
120
|
+
type: "Record<string, any>[]",
|
|
121
|
+
isOptional: true,
|
|
122
|
+
description: "Metadata for each vector",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "ids",
|
|
126
|
+
type: "string[]",
|
|
127
|
+
isOptional: true,
|
|
128
|
+
description: "Optional vector IDs (auto-generated if not provided)",
|
|
129
|
+
},
|
|
130
|
+
]}
|
|
131
|
+
/>
|
|
132
|
+
|
|
133
|
+
```typescript copy
|
|
134
|
+
await vectorStore.upsert({
|
|
135
|
+
indexName: "my_vectors",
|
|
136
|
+
vectors: [[0.1, 0.2, 0.3, ...]],
|
|
137
|
+
metadata: [{ label: "example" }],
|
|
138
|
+
ids: ["vec-1"],
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### query()
|
|
143
|
+
|
|
144
|
+
<PropertiesTable
|
|
145
|
+
content={[
|
|
146
|
+
{
|
|
147
|
+
name: "indexName",
|
|
148
|
+
type: "string",
|
|
149
|
+
description: "Name of the index to query",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "queryVector",
|
|
153
|
+
type: "number[]",
|
|
154
|
+
description: "Query vector",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "topK",
|
|
158
|
+
type: "number",
|
|
159
|
+
isOptional: true,
|
|
160
|
+
defaultValue: "10",
|
|
161
|
+
description: "Number of results to return",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "filter",
|
|
165
|
+
type: "Record<string, any>",
|
|
166
|
+
isOptional: true,
|
|
167
|
+
description: "Metadata filters",
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "includeVector",
|
|
171
|
+
type: "boolean",
|
|
172
|
+
isOptional: true,
|
|
173
|
+
defaultValue: "false",
|
|
174
|
+
description: "Whether to include the vector in the result",
|
|
175
|
+
},
|
|
176
|
+
]}
|
|
177
|
+
/>
|
|
178
|
+
|
|
179
|
+
```typescript copy
|
|
180
|
+
const results = await vectorStore.query({
|
|
181
|
+
indexName: "my_vectors",
|
|
182
|
+
queryVector: [0.1, 0.2, 0.3, ...],
|
|
183
|
+
topK: 5,
|
|
184
|
+
filter: { category: "documents" },
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### listIndexes()
|
|
189
|
+
|
|
190
|
+
Returns an array of index names as strings.
|
|
191
|
+
|
|
192
|
+
```typescript copy
|
|
193
|
+
const indexes = await vectorStore.listIndexes();
|
|
194
|
+
// ["my_vectors", "embeddings", ...]
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### describeIndex()
|
|
198
|
+
|
|
199
|
+
<PropertiesTable
|
|
200
|
+
content={[
|
|
201
|
+
{
|
|
202
|
+
name: "indexName",
|
|
203
|
+
type: "string",
|
|
204
|
+
description: "Name of the index to describe",
|
|
205
|
+
},
|
|
206
|
+
]}
|
|
207
|
+
/>
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
|
|
211
|
+
```typescript copy
|
|
212
|
+
interface IndexStats {
|
|
213
|
+
dimension: number;
|
|
214
|
+
count: number;
|
|
215
|
+
metric: "cosine" | "euclidean" | "dotproduct";
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### deleteIndex()
|
|
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
|
+
Deletes the index and all its vectors.
|
|
232
|
+
|
|
233
|
+
```typescript copy
|
|
234
|
+
await vectorStore.deleteIndex({ indexName: "my_vectors" });
|
|
235
|
+
```
|
|
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: "ID of the vector to update (mutually exclusive with filter)",
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: "filter",
|
|
256
|
+
type: "Record<string, any>",
|
|
257
|
+
isOptional: true,
|
|
258
|
+
description: "Metadata filter to identify vector(s) to update (mutually exclusive with id)",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "update",
|
|
262
|
+
type: "{ vector?: number[]; metadata?: Record<string, any>; }",
|
|
263
|
+
description: "Object containing the vector and/or metadata to update",
|
|
264
|
+
},
|
|
265
|
+
]}
|
|
266
|
+
/>
|
|
267
|
+
|
|
268
|
+
```typescript copy
|
|
269
|
+
// Update by ID
|
|
270
|
+
await vectorStore.updateVector({
|
|
271
|
+
indexName: "my_vectors",
|
|
272
|
+
id: "vector123",
|
|
273
|
+
update: {
|
|
274
|
+
vector: [0.1, 0.2, 0.3],
|
|
275
|
+
metadata: { label: "updated" },
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// Update by filter
|
|
280
|
+
await vectorStore.updateVector({
|
|
281
|
+
indexName: "my_vectors",
|
|
282
|
+
filter: { category: "product" },
|
|
283
|
+
update: {
|
|
284
|
+
metadata: { status: "reviewed" },
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### deleteVector()
|
|
290
|
+
|
|
291
|
+
<PropertiesTable
|
|
292
|
+
content={[
|
|
293
|
+
{
|
|
294
|
+
name: "indexName",
|
|
295
|
+
type: "string",
|
|
296
|
+
description: "Name of the index containing the vector",
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "id",
|
|
300
|
+
type: "string",
|
|
301
|
+
description: "ID of the vector to delete",
|
|
302
|
+
},
|
|
303
|
+
]}
|
|
304
|
+
/>
|
|
305
|
+
|
|
306
|
+
```typescript copy
|
|
307
|
+
await vectorStore.deleteVector({ indexName: "my_vectors", id: "vector123" });
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### deleteVectors()
|
|
311
|
+
|
|
312
|
+
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
313
|
+
|
|
314
|
+
<PropertiesTable
|
|
315
|
+
content={[
|
|
316
|
+
{
|
|
317
|
+
name: "indexName",
|
|
318
|
+
type: "string",
|
|
319
|
+
description: "Name of the index containing the vectors to delete",
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: "ids",
|
|
323
|
+
type: "string[]",
|
|
324
|
+
isOptional: true,
|
|
325
|
+
description: "Array of vector IDs to delete (mutually exclusive with filter)",
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "filter",
|
|
329
|
+
type: "Record<string, any>",
|
|
330
|
+
isOptional: true,
|
|
331
|
+
description: "Metadata filter to identify vectors to delete (mutually exclusive with ids)",
|
|
332
|
+
},
|
|
333
|
+
]}
|
|
334
|
+
/>
|
|
335
|
+
|
|
336
|
+
```typescript copy
|
|
337
|
+
// Delete by IDs
|
|
338
|
+
await vectorStore.deleteVectors({
|
|
339
|
+
indexName: "my_vectors",
|
|
340
|
+
ids: ["vec1", "vec2", "vec3"],
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Delete by filter
|
|
344
|
+
await vectorStore.deleteVectors({
|
|
345
|
+
indexName: "my_vectors",
|
|
346
|
+
filter: { status: "archived" },
|
|
347
|
+
});
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Response Types
|
|
351
|
+
|
|
352
|
+
Query results are returned in this format:
|
|
353
|
+
|
|
354
|
+
```typescript copy
|
|
355
|
+
interface QueryResult {
|
|
356
|
+
id: string;
|
|
357
|
+
score: number;
|
|
358
|
+
metadata: Record<string, any>;
|
|
359
|
+
vector?: number[]; // Only included if includeVector is true
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Metadata Filtering
|
|
364
|
+
|
|
365
|
+
ConvexVector supports metadata filtering with various operators:
|
|
366
|
+
|
|
367
|
+
```typescript copy
|
|
368
|
+
// Simple equality
|
|
369
|
+
const results = await vectorStore.query({
|
|
370
|
+
indexName: "my_vectors",
|
|
371
|
+
queryVector: embedding,
|
|
372
|
+
filter: { category: "documents" },
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// Comparison operators
|
|
376
|
+
const results = await vectorStore.query({
|
|
377
|
+
indexName: "my_vectors",
|
|
378
|
+
queryVector: embedding,
|
|
379
|
+
filter: {
|
|
380
|
+
price: { $gt: 100 },
|
|
381
|
+
status: { $in: ["active", "pending"] },
|
|
382
|
+
},
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// Logical operators
|
|
386
|
+
const results = await vectorStore.query({
|
|
387
|
+
indexName: "my_vectors",
|
|
388
|
+
queryVector: embedding,
|
|
389
|
+
filter: {
|
|
390
|
+
$and: [
|
|
391
|
+
{ category: "electronics" },
|
|
392
|
+
{ price: { $lte: 500 } },
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
});
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Supported Filter Operators
|
|
399
|
+
|
|
400
|
+
| Operator | Description |
|
|
401
|
+
| -------- | ----------- |
|
|
402
|
+
| `$eq` | Equal to |
|
|
403
|
+
| `$ne` | Not equal to |
|
|
404
|
+
| `$gt` | Greater than |
|
|
405
|
+
| `$gte` | Greater than or equal |
|
|
406
|
+
| `$lt` | Less than |
|
|
407
|
+
| `$lte` | Less than or equal |
|
|
408
|
+
| `$in` | In array |
|
|
409
|
+
| `$nin` | Not in array |
|
|
410
|
+
| `$and` | Logical AND |
|
|
411
|
+
| `$or` | Logical OR |
|
|
412
|
+
|
|
413
|
+
## Architecture
|
|
414
|
+
|
|
415
|
+
ConvexVector stores vectors in the `mastra_vectors` table with the following structure:
|
|
416
|
+
|
|
417
|
+
- `id`: Unique vector identifier
|
|
418
|
+
- `indexName`: Name of the index
|
|
419
|
+
- `embedding`: The vector data (array of floats)
|
|
420
|
+
- `metadata`: Optional JSON metadata
|
|
421
|
+
|
|
422
|
+
Vector similarity search is performed using cosine similarity, computed in the Convex function.
|
|
423
|
+
|
|
424
|
+
## Related
|
|
425
|
+
|
|
426
|
+
- [Convex Storage](../storage/convex)
|
|
427
|
+
- [Metadata Filters](../rag/metadata-filters)
|
|
428
|
+
- [Convex Documentation](https://docs.convex.dev/)
|
|
429
|
+
|