@mastra/qdrant 1.0.0-beta.3 → 1.0.0-beta.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # @mastra/qdrant
2
2
 
3
+ ## 1.0.0-beta.5
4
+
5
+ ### Minor Changes
6
+
7
+ - Add full support for Qdrant named vectors, allowing collections with multiple vector spaces. ([#11905](https://github.com/mastra-ai/mastra/pull/11905))
8
+ - Added `namedVectors` parameter to `createIndex()` for creating multi-vector collections
9
+ - Added `vectorName` parameter to `upsert()` for inserting into specific vector spaces
10
+ - Added `using` parameter to `query()` for querying specific vector spaces
11
+ - Changed `client` from `private` to `protected` to enable subclass extension
12
+ - Added vector name validation when upserting to named vector collections
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [[`1dbd8c7`](https://github.com/mastra-ai/mastra/commit/1dbd8c729fb6536ec52f00064d76b80253d346e9), [`c59e13c`](https://github.com/mastra-ai/mastra/commit/c59e13c7688284bd96b2baee3e314335003548de), [`f9a2509`](https://github.com/mastra-ai/mastra/commit/f9a25093ea72d210a5e52cfcb3bcc8b5e02dc25c), [`7a010c5`](https://github.com/mastra-ai/mastra/commit/7a010c56b846a313a49ae42fccd3d8de2b9f292d)]:
17
+ - @mastra/core@1.0.0-beta.24
18
+
19
+ ## 1.0.0-beta.4
20
+
21
+ ### Minor Changes
22
+
23
+ - Added support for creating payload (metadata) indexes in Qdrant ([#11839](https://github.com/mastra-ai/mastra/pull/11839))
24
+
25
+ Qdrant Cloud and deployments with `strict_mode_config = true` require explicit payload indexes for metadata filtering. This release adds two new methods to `QdrantVector`:
26
+
27
+ **New exports:**
28
+ - `PayloadSchemaType` - Union type for Qdrant payload schema types ('keyword', 'integer', 'float', 'geo', 'text', 'bool', 'datetime', 'uuid')
29
+ - `CreatePayloadIndexParams` - Parameters interface for creating payload indexes
30
+ - `DeletePayloadIndexParams` - Parameters interface for deleting payload indexes
31
+
32
+ **New methods:**
33
+ - `createPayloadIndex()` - Creates a payload index on a collection field for efficient filtering
34
+ - `deletePayloadIndex()` - Removes a payload index from a collection field
35
+
36
+ **Example usage:**
37
+
38
+ ```typescript
39
+ import { QdrantVector } from '@mastra/qdrant';
40
+
41
+ const qdrant = new QdrantVector({ url: `http://localhost:6333`, id: 'my-store' });
42
+
43
+ // Create a keyword index for filtering by source
44
+ await qdrant.createPayloadIndex({
45
+ indexName: 'my-collection',
46
+ fieldName: 'source',
47
+ fieldSchema: 'keyword',
48
+ });
49
+
50
+ // Now filtering works in strict mode environments
51
+ const results = await qdrant.query({
52
+ indexName: 'my-collection',
53
+ queryVector: embeddings,
54
+ filter: { source: 'document-a' },
55
+ });
56
+ ```
57
+
58
+ Closes #8923
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [[`ebae12a`](https://github.com/mastra-ai/mastra/commit/ebae12a2dd0212e75478981053b148a2c246962d), [`c61a0a5`](https://github.com/mastra-ai/mastra/commit/c61a0a5de4904c88fd8b3718bc26d1be1c2ec6e7), [`69136e7`](https://github.com/mastra-ai/mastra/commit/69136e748e32f57297728a4e0f9a75988462f1a7), [`449aed2`](https://github.com/mastra-ai/mastra/commit/449aed2ba9d507b75bf93d427646ea94f734dfd1), [`eb648a2`](https://github.com/mastra-ai/mastra/commit/eb648a2cc1728f7678768dd70cd77619b448dab9), [`0131105`](https://github.com/mastra-ai/mastra/commit/0131105532e83bdcbb73352fc7d0879eebf140dc), [`9d5059e`](https://github.com/mastra-ai/mastra/commit/9d5059eae810829935fb08e81a9bb7ecd5b144a7), [`ef756c6`](https://github.com/mastra-ai/mastra/commit/ef756c65f82d16531c43f49a27290a416611e526), [`b00ccd3`](https://github.com/mastra-ai/mastra/commit/b00ccd325ebd5d9e37e34dd0a105caae67eb568f), [`3bdfa75`](https://github.com/mastra-ai/mastra/commit/3bdfa7507a91db66f176ba8221aa28dd546e464a), [`e770de9`](https://github.com/mastra-ai/mastra/commit/e770de941a287a49b1964d44db5a5763d19890a6), [`52e2716`](https://github.com/mastra-ai/mastra/commit/52e2716b42df6eff443de72360ae83e86ec23993), [`27b4040`](https://github.com/mastra-ai/mastra/commit/27b4040bfa1a95d92546f420a02a626b1419a1d6), [`610a70b`](https://github.com/mastra-ai/mastra/commit/610a70bdad282079f0c630e0d7bb284578f20151), [`8dc7f55`](https://github.com/mastra-ai/mastra/commit/8dc7f55900395771da851dc7d78d53ae84fe34ec), [`8379099`](https://github.com/mastra-ai/mastra/commit/8379099fc467af6bef54dd7f80c9bd75bf8bbddf), [`8c0ec25`](https://github.com/mastra-ai/mastra/commit/8c0ec25646c8a7df253ed1e5ff4863a0d3f1316c), [`ff4d9a6`](https://github.com/mastra-ai/mastra/commit/ff4d9a6704fc87b31a380a76ed22736fdedbba5a), [`69821ef`](https://github.com/mastra-ai/mastra/commit/69821ef806482e2c44e2197ac0b050c3fe3a5285), [`1ed5716`](https://github.com/mastra-ai/mastra/commit/1ed5716830867b3774c4a1b43cc0d82935f32b96), [`4186bdd`](https://github.com/mastra-ai/mastra/commit/4186bdd00731305726fa06adba0b076a1d50b49f), [`7aaf973`](https://github.com/mastra-ai/mastra/commit/7aaf973f83fbbe9521f1f9e7a4fd99b8de464617)]:
63
+ - @mastra/core@1.0.0-beta.22
64
+
3
65
  ## 1.0.0-beta.3
4
66
 
5
67
  ### Patch Changes
package/README.md CHANGED
@@ -13,11 +13,11 @@ pnpm add @mastra/qdrant
13
13
  ```typescript
14
14
  import { QdrantVector } from '@mastra/qdrant';
15
15
 
16
- const vectorStore = new QdrantVector(
17
- 'http://localhost:6333', // url
18
- 'optional-api-key', // optional
19
- false // https (optional)
20
- );
16
+ const vectorStore = new QdrantVector({
17
+ id: 'my-qdrant',
18
+ url: 'http://localhost:6333',
19
+ apiKey: 'optional-api-key', // optional
20
+ });
21
21
 
22
22
  // Create a new collection
23
23
  await vectorStore.createIndex({ indexName: 'myCollection', dimension: 1536, metric: 'cosine' });
@@ -31,9 +31,61 @@ const ids = await vectorStore.upsert({ indexName: 'myCollection', vectors, metad
31
31
  const results = await vectorStore.query({
32
32
  indexName: 'myCollection',
33
33
  queryVector: [0.1, 0.2, ...],
34
- topK: 10, // topK
34
+ topK: 10,
35
35
  filter: { text: { $eq: 'doc1' } }, // optional filter
36
- includeVector: false // includeVector
36
+ includeVector: false,
37
+ });
38
+
39
+ // Query with named vectors (for collections with multiple vector fields)
40
+ const namedResults = await vectorStore.query({
41
+ indexName: 'myCollection',
42
+ queryVector: [0.1, 0.2, ...],
43
+ topK: 10,
44
+ using: 'title_embedding', // specify which named vector to query
45
+ });
46
+ ```
47
+
48
+ ## Named Vectors
49
+
50
+ Qdrant supports [named vectors](https://qdrant.tech/documentation/concepts/vectors/#named-vectors), allowing multiple vector fields per collection. This is useful for multi-modal data (text + images) or different embedding models.
51
+
52
+ ```typescript
53
+ // Create a collection with multiple named vector spaces
54
+ await vectorStore.createIndex({
55
+ indexName: 'multi_modal',
56
+ dimension: 768, // fallback
57
+ namedVectors: {
58
+ text: { size: 768, distance: 'cosine' },
59
+ image: { size: 512, distance: 'euclidean' },
60
+ },
61
+ });
62
+
63
+ // Upsert into specific vector spaces
64
+ await vectorStore.upsert({
65
+ indexName: 'multi_modal',
66
+ vectors: textEmbeddings,
67
+ metadata: [{ type: 'text' }],
68
+ vectorName: 'text', // target the text vector space
69
+ });
70
+
71
+ await vectorStore.upsert({
72
+ indexName: 'multi_modal',
73
+ vectors: imageEmbeddings,
74
+ metadata: [{ type: 'image' }],
75
+ vectorName: 'image', // target the image vector space
76
+ });
77
+
78
+ // Query specific vector spaces
79
+ const textResults = await vectorStore.query({
80
+ indexName: 'multi_modal',
81
+ queryVector: textQuery,
82
+ using: 'text',
83
+ });
84
+
85
+ const imageResults = await vectorStore.query({
86
+ indexName: 'multi_modal',
87
+ queryVector: imageQuery,
88
+ using: 'image',
37
89
  });
38
90
  ```
39
91
 
@@ -41,6 +93,7 @@ const results = await vectorStore.query({
41
93
 
42
94
  Required:
43
95
 
96
+ - `id`: Unique identifier for this vector store instance
44
97
  - `url`: URL of your Qdrant instance
45
98
 
46
99
  Optional:
@@ -51,6 +104,7 @@ Optional:
51
104
  ## Features
52
105
 
53
106
  - Vector similarity search with Cosine, Euclidean, and Dot Product metrics
107
+ - [Named vectors](https://qdrant.tech/documentation/concepts/vectors/#named-vectors) support for collections with multiple vector fields
54
108
  - Automatic batching for large upserts (256 vectors per batch)
55
109
  - Built-in telemetry support
56
110
  - Metadata filtering
@@ -69,12 +123,14 @@ The following distance metrics are supported:
69
123
 
70
124
  ## Methods
71
125
 
72
- - `createIndex({ indexName, dimension, metric? })`: Create a new collection
73
- - `upsert({ indexName, vectors, metadata?, ids? })`: Add or update vectors
74
- - `query({ indexName, queryVector, topK?, filter?, includeVector? })`: Search for similar vectors
126
+ - `createIndex({ indexName, dimension, metric?, namedVectors? })`: Create a new collection (supports named vectors)
127
+ - `upsert({ indexName, vectors, metadata?, ids?, vectorName? })`: Add or update vectors (supports named vectors)
128
+ - `query({ indexName, queryVector, topK?, filter?, includeVector?, using? })`: Search for similar vectors
75
129
  - `updateVector({ indexName, id?, filter?, update })`: Update a single vector by ID or metadata filter
76
130
  - `deleteVector({ indexName, id })`: Delete a single vector by ID
77
131
  - `deleteVectors({ indexName, ids?, filter? })`: Delete multiple vectors by IDs or metadata filter
132
+ - `createPayloadIndex({ indexName, fieldName, fieldSchema, wait? })`: Create a payload index for filtering
133
+ - `deletePayloadIndex({ indexName, fieldName, wait? })`: Delete a payload index
78
134
  - `listIndexes()`: List all collections
79
135
  - `describeIndex(indexName)`: Get collection statistics
80
136
  - `deleteIndex(indexName)`: Delete a collection
@@ -29,4 +29,4 @@ docs/
29
29
  ## Version
30
30
 
31
31
  Package: @mastra/qdrant
32
- Version: 1.0.0-beta.3
32
+ Version: 1.0.0-beta.5
@@ -5,7 +5,7 @@ description: Documentation for @mastra/qdrant. Includes links to type definition
5
5
 
6
6
  # @mastra/qdrant Documentation
7
7
 
8
- > **Version**: 1.0.0-beta.3
8
+ > **Version**: 1.0.0-beta.5
9
9
  > **Package**: @mastra/qdrant
10
10
 
11
11
  ## Quick Navigation
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-beta.3",
2
+ "version": "1.0.0-beta.5",
3
3
  "package": "@mastra/qdrant",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -12,6 +12,7 @@ After generating embeddings, you need to store them in a database that supports
12
12
  import { MongoDBVector } from "@mastra/mongodb";
13
13
 
14
14
  const store = new MongoDBVector({
15
+ id: 'mongodb-vector',
15
16
  uri: process.env.MONGODB_URI,
16
17
  dbName: process.env.MONGODB_DATABASE,
17
18
  });
@@ -26,7 +27,7 @@ await store.upsert({
26
27
  });
27
28
  ```
28
29
 
29
- ### Using MongoDB Atlas Vector search
30
+ <h3>Using MongoDB Atlas Vector search</h3>
30
31
 
31
32
  For detailed setup instructions and best practices, see the [official MongoDB Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/?utm_campaign=devrel&utm_source=third-party-content&utm_medium=cta&utm_content=mastra-docs).
32
33
 
@@ -54,7 +55,7 @@ await store.upsert({
54
55
  });
55
56
  ```
56
57
 
57
- ### Using PostgreSQL with pgvector
58
+ <h3>Using PostgreSQL with pgvector</h3>
58
59
 
59
60
  PostgreSQL with the pgvector extension is a good solution for teams already using PostgreSQL who want to minimize infrastructure complexity.
60
61
  For detailed setup instructions and best practices, see the [official pgvector repository](https://github.com/pgvector/pgvector).
@@ -144,6 +145,7 @@ await store.upsert({
144
145
  import { AstraVector } from "@mastra/astra";
145
146
 
146
147
  const store = new AstraVector({
148
+ id: 'astra-vector',
147
149
  token: process.env.ASTRA_DB_TOKEN,
148
150
  endpoint: process.env.ASTRA_DB_ENDPOINT,
149
151
  keyspace: process.env.ASTRA_DB_KEYSPACE,
@@ -170,7 +172,7 @@ import { LibSQLVector } from "@mastra/core/vector/libsql";
170
172
 
171
173
  const store = new LibSQLVector({
172
174
  id: 'libsql-vector',
173
- connectionUrl: process.env.DATABASE_URL,
175
+ url: process.env.DATABASE_URL,
174
176
  authToken: process.env.DATABASE_AUTH_TOKEN, // Optional: for Turso cloud databases
175
177
  });
176
178
 
@@ -217,6 +219,7 @@ await store.upsert({
217
219
  import { CloudflareVector } from "@mastra/vectorize";
218
220
 
219
221
  const store = new CloudflareVector({
222
+ id: 'cloudflare-vector',
220
223
  accountId: process.env.CF_ACCOUNT_ID,
221
224
  apiToken: process.env.CF_API_TOKEN,
222
225
  });
@@ -238,7 +241,7 @@ await store.upsert({
238
241
  ```ts title="vector-store.ts"
239
242
  import { OpenSearchVector } from "@mastra/opensearch";
240
243
 
241
- const store = new OpenSearchVector({ url: process.env.OPENSEARCH_URL });
244
+ const store = new OpenSearchVector({ id: "opensearch", node: process.env.OPENSEARCH_URL });
242
245
 
243
246
  await store.createIndex({
244
247
  indexName: "my-collection",
@@ -259,7 +262,7 @@ await store.upsert({
259
262
  ```ts title="vector-store.ts"
260
263
  import { ElasticSearchVector } from "@mastra/elasticsearch";
261
264
 
262
- const store = new ElasticSearchVector({ url: process.env.ELASTICSEARCH_URL });
265
+ const store = new ElasticSearchVector({ id: 'elasticsearch-vector', url: process.env.ELASTICSEARCH_URL });
263
266
 
264
267
  await store.createIndex({
265
268
  indexName: "my-collection",
@@ -280,6 +283,7 @@ await store.upsert({
280
283
  import { CouchbaseVector } from "@mastra/couchbase";
281
284
 
282
285
  const store = new CouchbaseVector({
286
+ id: 'couchbase-vector',
283
287
  connectionString: process.env.COUCHBASE_CONNECTION_STRING,
284
288
  username: process.env.COUCHBASE_USERNAME,
285
289
  password: process.env.COUCHBASE_PASSWORD,
@@ -319,7 +323,7 @@ await store.upsert({
319
323
  });
320
324
  ```
321
325
 
322
- ### Using LanceDB
326
+ <h3>Using LanceDB</h3>
323
327
 
324
328
  LanceDB is an embedded vector database built on the Lance columnar format, suitable for local development or cloud deployment.
325
329
  For detailed setup instructions and best practices, see the [official LanceDB documentation](https://lancedb.github.io/lancedb/).
@@ -331,6 +335,7 @@ For detailed setup instructions and best practices, see the [official LanceDB do
331
335
  import { S3Vectors } from "@mastra/s3vectors";
332
336
 
333
337
  const store = new S3Vectors({
338
+ id: 's3-vectors',
334
339
  vectorBucketName: "my-vector-bucket",
335
340
  clientConfig: {
336
341
  region: "us-east-1",
@@ -373,7 +378,7 @@ The dimension size must match the output dimension of your chosen embedding mode
373
378
  - Cohere embed-multilingual-v3: 1024 dimensions
374
379
  - Google text-embedding-004: 768 dimensions (or custom)
375
380
 
376
- important
381
+ > **Note:**
377
382
  Index dimensions cannot be changed after creation. To use a different model, delete and recreate the index with the new dimension size.
378
383
 
379
384
  ### Naming Rules for Databases
@@ -537,7 +542,7 @@ The upsert operation:
537
542
 
538
543
  Vector stores support rich metadata (any JSON-serializable fields) for filtering and organization. Since metadata is stored with no fixed schema, use consistent field naming to avoid unexpected query results.
539
544
 
540
- important
545
+ > **Note:**
541
546
  Metadata is crucial for vector storage - without it, you'd only have numerical embeddings with no way to return the original text or filter results. Always store at least the source text as metadata.
542
547
 
543
548
  ```ts
@@ -171,7 +171,7 @@ The Vector Query Tool supports database-specific configurations that enable you
171
171
  > **Note:**
172
172
  These configurations are for **query-time options** like namespaces, performance tuning, and filtering—not for database connection setup.
173
173
 
174
- Connection credentials (URLs, auth tokens) are configured when you instantiate the vector store class (e.g., `new LibSQLVector({ connectionUrl: '...' })`).
174
+ Connection credentials (URLs, auth tokens) are configured when you instantiate the vector store class (e.g., `new LibSQLVector({ url: '...' })`).
175
175
 
176
176
  ```ts
177
177
  import { createVectorQueryTool } from "@mastra/rag";
@@ -258,11 +258,10 @@ requestContext.set("databaseConfig", {
258
258
  },
259
259
  });
260
260
 
261
- await pineconeQueryTool.execute({
262
- context: { queryText: "search query" },
263
- mastra,
264
- requestContext,
265
- });
261
+ await pineconeQueryTool.execute(
262
+ { queryText: "search query" },
263
+ { mastra, requestContext }
264
+ );
266
265
  ```
267
266
 
268
267
  For detailed configuration options and advanced usage, see the [Vector Query Tool Reference](https://mastra.ai/reference/v1/tools/vector-query-tool).
@@ -18,10 +18,57 @@ It provides a production-ready service with a convenient API to store, search, a
18
18
 
19
19
  ### createIndex()
20
20
 
21
+ #### Creating a Named Vectors Collection
22
+
23
+ ```typescript
24
+ // Create a collection with multiple named vector spaces
25
+ await store.createIndex({
26
+ indexName: "multi_modal",
27
+ dimension: 768, // fallback
28
+ namedVectors: {
29
+ text: { size: 768, distance: "cosine" },
30
+ image: { size: 512, distance: "euclidean" },
31
+ },
32
+ });
33
+ ```
34
+
21
35
  ### upsert()
22
36
 
37
+ #### Upserting into Named Vector Spaces
38
+
39
+ ```typescript
40
+ // Upsert into the "text" vector space
41
+ await store.upsert({
42
+ indexName: "multi_modal",
43
+ vectors: textEmbeddings,
44
+ metadata: textMetadata,
45
+ vectorName: "text",
46
+ });
47
+
48
+ // Upsert into the "image" vector space
49
+ await store.upsert({
50
+ indexName: "multi_modal",
51
+ vectors: imageEmbeddings,
52
+ metadata: imageMetadata,
53
+ vectorName: "image",
54
+ });
55
+ ```
56
+
23
57
  ### query()
24
58
 
59
+ #### Named Vectors
60
+
61
+ Qdrant supports [named vectors](https://qdrant.tech/documentation/concepts/vectors/#named-vectors), allowing multiple vector fields per collection. Use the `using` parameter to specify which named vector to query against:
62
+
63
+ ```typescript
64
+ const results = await store.query({
65
+ indexName: "my_index",
66
+ queryVector: embedding,
67
+ topK: 10,
68
+ using: "title_embedding", // Query against a specific named vector
69
+ });
70
+ ```
71
+
25
72
  ### listIndexes()
26
73
 
27
74
  Returns an array of index names as strings.
@@ -54,6 +101,29 @@ Deletes a vector from the specified index by its ID.
54
101
 
55
102
  Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
56
103
 
104
+ ### createPayloadIndex()
105
+
106
+ Creates a payload (metadata) index on a collection field to enable efficient filtering. This is **required** for Qdrant Cloud and any Qdrant instance with `strict_mode_config = true`.
107
+
108
+ ```typescript
109
+ // Create a keyword index for filtering by source
110
+ await store.createPayloadIndex({
111
+ indexName: "my_index",
112
+ fieldName: "source",
113
+ fieldSchema: "keyword",
114
+ });
115
+
116
+ const results = await store.query({
117
+ indexName: "my_index",
118
+ queryVector: queryVector,
119
+ filter: { source: "document-a" },
120
+ });
121
+ ```
122
+
123
+ ### deletePayloadIndex()
124
+
125
+ Removes a payload index from a collection field.
126
+
57
127
  ## Response Types
58
128
 
59
129
  Query results are returned in this format: