@mastra/qdrant 1.1.5 → 1.1.6-alpha.0
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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-rag-retrieval.md +24 -13
- package/dist/index.cjs +3 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -8
- package/dist/index.js.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +10 -10
package/dist/docs/SKILL.md
CHANGED
|
@@ -382,11 +382,12 @@ Vector store prompts define query patterns and filtering capabilities for each v
|
|
|
382
382
|
|
|
383
383
|
```ts
|
|
384
384
|
import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
385
|
+
import { Agent } from '@mastra/core/agent'
|
|
385
386
|
|
|
386
387
|
export const ragAgent = new Agent({
|
|
387
388
|
id: 'rag-agent',
|
|
388
389
|
name: 'RAG Agent',
|
|
389
|
-
model: 'openai/gpt-
|
|
390
|
+
model: 'openai/gpt-6.1-sol',
|
|
390
391
|
instructions: `
|
|
391
392
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
392
393
|
${MONGODB_PROMPT}
|
|
@@ -403,7 +404,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
403
404
|
export const ragAgent = new Agent({
|
|
404
405
|
id: 'rag-agent',
|
|
405
406
|
name: 'RAG Agent',
|
|
406
|
-
model: 'openai/gpt-
|
|
407
|
+
model: 'openai/gpt-6.1-sol',
|
|
407
408
|
instructions: `
|
|
408
409
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
409
410
|
${PGVECTOR_PROMPT}
|
|
@@ -416,11 +417,12 @@ export const ragAgent = new Agent({
|
|
|
416
417
|
|
|
417
418
|
```ts
|
|
418
419
|
import { PINECONE_PROMPT } from '@mastra/pinecone'
|
|
420
|
+
import { Agent } from '@mastra/core/agent'
|
|
419
421
|
|
|
420
422
|
export const ragAgent = new Agent({
|
|
421
423
|
id: 'rag-agent',
|
|
422
424
|
name: 'RAG Agent',
|
|
423
|
-
model: 'openai/gpt-
|
|
425
|
+
model: 'openai/gpt-6.1-sol',
|
|
424
426
|
instructions: `
|
|
425
427
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
426
428
|
${PINECONE_PROMPT}
|
|
@@ -433,11 +435,12 @@ export const ragAgent = new Agent({
|
|
|
433
435
|
|
|
434
436
|
```ts
|
|
435
437
|
import { QDRANT_PROMPT } from '@mastra/qdrant'
|
|
438
|
+
import { Agent } from '@mastra/core/agent'
|
|
436
439
|
|
|
437
440
|
export const ragAgent = new Agent({
|
|
438
441
|
id: 'rag-agent',
|
|
439
442
|
name: 'RAG Agent',
|
|
440
|
-
model: 'openai/gpt-
|
|
443
|
+
model: 'openai/gpt-6.1-sol',
|
|
441
444
|
instructions: `
|
|
442
445
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
443
446
|
${QDRANT_PROMPT}
|
|
@@ -450,11 +453,12 @@ export const ragAgent = new Agent({
|
|
|
450
453
|
|
|
451
454
|
```ts
|
|
452
455
|
import { CHROMA_PROMPT } from '@mastra/chroma'
|
|
456
|
+
import { Agent } from '@mastra/core/agent'
|
|
453
457
|
|
|
454
458
|
export const ragAgent = new Agent({
|
|
455
459
|
id: 'rag-agent',
|
|
456
460
|
name: 'RAG Agent',
|
|
457
|
-
model: 'openai/gpt-
|
|
461
|
+
model: 'openai/gpt-6.1-sol',
|
|
458
462
|
instructions: `
|
|
459
463
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
460
464
|
${CHROMA_PROMPT}
|
|
@@ -467,11 +471,12 @@ export const ragAgent = new Agent({
|
|
|
467
471
|
|
|
468
472
|
```ts
|
|
469
473
|
import { ASTRA_PROMPT } from '@mastra/astra'
|
|
474
|
+
import { Agent } from '@mastra/core/agent'
|
|
470
475
|
|
|
471
476
|
export const ragAgent = new Agent({
|
|
472
477
|
id: 'rag-agent',
|
|
473
478
|
name: 'RAG Agent',
|
|
474
|
-
model: 'openai/gpt-
|
|
479
|
+
model: 'openai/gpt-6.1-sol',
|
|
475
480
|
instructions: `
|
|
476
481
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
477
482
|
${ASTRA_PROMPT}
|
|
@@ -484,11 +489,12 @@ export const ragAgent = new Agent({
|
|
|
484
489
|
|
|
485
490
|
```ts
|
|
486
491
|
import { LIBSQL_PROMPT } from '@mastra/libsql'
|
|
492
|
+
import { Agent } from '@mastra/core/agent'
|
|
487
493
|
|
|
488
494
|
export const ragAgent = new Agent({
|
|
489
495
|
id: 'rag-agent',
|
|
490
496
|
name: 'RAG Agent',
|
|
491
|
-
model: 'openai/gpt-
|
|
497
|
+
model: 'openai/gpt-6.1-sol',
|
|
492
498
|
instructions: `
|
|
493
499
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
494
500
|
${LIBSQL_PROMPT}
|
|
@@ -501,11 +507,12 @@ export const ragAgent = new Agent({
|
|
|
501
507
|
|
|
502
508
|
```ts
|
|
503
509
|
import { UPSTASH_PROMPT } from '@mastra/upstash'
|
|
510
|
+
import { Agent } from '@mastra/core/agent'
|
|
504
511
|
|
|
505
512
|
export const ragAgent = new Agent({
|
|
506
513
|
id: 'rag-agent',
|
|
507
514
|
name: 'RAG Agent',
|
|
508
|
-
model: 'openai/gpt-
|
|
515
|
+
model: 'openai/gpt-6.1-sol',
|
|
509
516
|
instructions: `
|
|
510
517
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
511
518
|
${UPSTASH_PROMPT}
|
|
@@ -518,11 +525,12 @@ export const ragAgent = new Agent({
|
|
|
518
525
|
|
|
519
526
|
```ts
|
|
520
527
|
import { VECTORIZE_PROMPT } from '@mastra/vectorize'
|
|
528
|
+
import { Agent } from '@mastra/core/agent'
|
|
521
529
|
|
|
522
530
|
export const ragAgent = new Agent({
|
|
523
531
|
id: 'rag-agent',
|
|
524
532
|
name: 'RAG Agent',
|
|
525
|
-
model: 'openai/gpt-
|
|
533
|
+
model: 'openai/gpt-6.1-sol',
|
|
526
534
|
instructions: `
|
|
527
535
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
528
536
|
${VECTORIZE_PROMPT}
|
|
@@ -535,11 +543,12 @@ export const ragAgent = new Agent({
|
|
|
535
543
|
|
|
536
544
|
```ts
|
|
537
545
|
import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
|
|
546
|
+
import { Agent } from '@mastra/core/agent'
|
|
538
547
|
|
|
539
548
|
export const ragAgent = new Agent({
|
|
540
549
|
id: 'rag-agent',
|
|
541
550
|
name: 'RAG Agent',
|
|
542
|
-
model: 'openai/gpt-
|
|
551
|
+
model: 'openai/gpt-6.1-sol',
|
|
543
552
|
instructions: `
|
|
544
553
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
545
554
|
${OPENSEARCH_PROMPT}
|
|
@@ -552,11 +561,12 @@ export const ragAgent = new Agent({
|
|
|
552
561
|
|
|
553
562
|
```ts
|
|
554
563
|
import { ORACLEDB_PROMPT } from '@mastra/oracledb'
|
|
564
|
+
import { Agent } from '@mastra/core/agent'
|
|
555
565
|
|
|
556
566
|
export const ragAgent = new Agent({
|
|
557
567
|
id: 'rag-agent',
|
|
558
568
|
name: 'RAG Agent',
|
|
559
|
-
model: 'openai/gpt-
|
|
569
|
+
model: 'openai/gpt-6.1-sol',
|
|
560
570
|
instructions: `
|
|
561
571
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
562
572
|
${ORACLEDB_PROMPT}
|
|
@@ -569,11 +579,12 @@ export const ragAgent = new Agent({
|
|
|
569
579
|
|
|
570
580
|
```ts
|
|
571
581
|
import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
|
|
582
|
+
import { Agent } from '@mastra/core/agent'
|
|
572
583
|
|
|
573
584
|
export const ragAgent = new Agent({
|
|
574
585
|
id: 'rag-agent',
|
|
575
586
|
name: 'RAG Agent',
|
|
576
|
-
model: 'openai/gpt-
|
|
587
|
+
model: 'openai/gpt-6.1-sol',
|
|
577
588
|
instructions: `
|
|
578
589
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
579
590
|
${S3VECTORS_PROMPT}
|
|
@@ -605,7 +616,7 @@ const initialResults = await pgVector.query({
|
|
|
605
616
|
// Create a relevance scorer
|
|
606
617
|
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
607
618
|
'relevance-scorer',
|
|
608
|
-
'openai/gpt-
|
|
619
|
+
'openai/gpt-6.1-sol',
|
|
609
620
|
)
|
|
610
621
|
|
|
611
622
|
// Re-rank the results
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ let _mastra_core_storage = require("@mastra/core/storage");
|
|
|
4
4
|
let _mastra_core_vector = require("@mastra/core/vector");
|
|
5
5
|
let _qdrant_js_client_rest = require("@qdrant/js-client-rest");
|
|
6
6
|
let _mastra_core_vector_filter = require("@mastra/core/vector/filter");
|
|
7
|
-
|
|
7
|
+
// src/vector/filter.ts
|
|
8
8
|
/**
|
|
9
9
|
* Translates MongoDB-style filters to Qdrant compatible filters.
|
|
10
10
|
*
|
|
@@ -231,8 +231,7 @@ var QdrantFilterTranslator = class extends _mastra_core_vector_filter.BaseFilter
|
|
|
231
231
|
return range;
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
|
|
235
|
-
//#region src/vector/index.ts
|
|
234
|
+
// src/vector/index.ts
|
|
236
235
|
const BATCH_SIZE = 256;
|
|
237
236
|
const DISTANCE_MAPPING = {
|
|
238
237
|
cosine: "Cosine",
|
|
@@ -582,7 +581,6 @@ var QdrantVector = class extends _mastra_core_vector.MastraVector {
|
|
|
582
581
|
payload: update.metadata
|
|
583
582
|
};
|
|
584
583
|
await this.client.upsert(indexName, { points: [point] });
|
|
585
|
-
return;
|
|
586
584
|
}
|
|
587
585
|
} else if (filter) {
|
|
588
586
|
const translatedFilter = this.transformFilter(filter);
|
|
@@ -625,7 +623,6 @@ var QdrantVector = class extends _mastra_core_vector.MastraVector {
|
|
|
625
623
|
wait: true
|
|
626
624
|
});
|
|
627
625
|
}
|
|
628
|
-
return;
|
|
629
626
|
}
|
|
630
627
|
}
|
|
631
628
|
} catch (error) {
|
|
@@ -933,8 +930,7 @@ var QdrantVector = class extends _mastra_core_vector.MastraVector {
|
|
|
933
930
|
}
|
|
934
931
|
}
|
|
935
932
|
};
|
|
936
|
-
|
|
937
|
-
//#region src/vector/prompt.ts
|
|
933
|
+
// src/vector/prompt.ts
|
|
938
934
|
/**
|
|
939
935
|
* Vector store specific prompt that details supported operators and examples.
|
|
940
936
|
* This prompt helps users construct valid filters for Qdrant Vector.
|
|
@@ -1020,7 +1016,6 @@ Example Complex Query:
|
|
|
1020
1016
|
{ "$not": { "status": "discontinued" } }
|
|
1021
1017
|
]
|
|
1022
1018
|
}`;
|
|
1023
|
-
//#endregion
|
|
1024
1019
|
exports.QDRANT_PROMPT = QDRANT_PROMPT;
|
|
1025
1020
|
exports.QdrantVector = QdrantVector;
|
|
1026
1021
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["BaseFilterTranslator","MastraVector","QdrantClient","MastraError","createVectorErrorId","ErrorDomain","ErrorCategory"],"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n LogicalOperator,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch'> & {\n /**\n * $count: Filter by array length or value count.\n * Example: { tags: { $count: { gt: 2 } } }\n */\n $count: {\n $gt?: number;\n $gte?: number;\n $lt?: number;\n $lte?: number;\n $eq?: number;\n };\n\n /**\n * $geo: Geospatial filter.\n * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }\n */\n $geo: {\n type: string;\n [key: string]: any;\n };\n\n /**\n * $hasId: Filter by point IDs.\n * Allowed at root level.\n * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }\n */\n $hasId: string | string[];\n\n /**\n * $nested: Nested object filter.\n * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }\n */\n $nested: {\n // Additional properties depend on the nested object structure\n [key: string]: any;\n };\n\n /**\n * $hasVector: Filter by vector existence or field.\n * Allowed at root level.\n * Example: { $hasVector: true } or { $hasVector: 'vector_field' }\n */\n $hasVector: boolean | string;\n\n /**\n * $datetime: RFC 3339 datetime range.\n * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }\n */\n $datetime: {\n key?: string;\n range?: {\n gt?: Date | string;\n gte?: Date | string;\n lt?: Date | string;\n lte?: Date | string;\n eq?: Date | string;\n };\n };\n\n /**\n * $null: Check if a field is null.\n * Example: { metadata: { $null: true } }\n */\n $null: boolean;\n\n /**\n * $empty: Check if an array or object field is empty.\n * Example: { tags: { $empty: true } }\n */\n $empty: boolean;\n};\n\ntype QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype QdrantBlacklistedRootOperators =\n | BlacklistedRootOperators\n | '$count'\n | '$geo'\n | '$nested'\n | '$datetime'\n | '$null'\n | '$empty';\n\nexport type QdrantVectorFilter = VectorFilter<\n keyof QdrantOperatorValueMap,\n QdrantOperatorValueMap,\n QdrantLogicalOperatorValueMap,\n QdrantBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters to Qdrant compatible filters.\n *\n * Key transformations:\n * - $and -> must\n * - $or -> should\n * - $not -> must_not\n * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }\n *\n * Custom operators (Qdrant-specific):\n * - $count -> values_count (array length/value count)\n * - $geo -> geo filters (box, radius, polygon)\n * - $hasId -> has_id filter\n * - $nested -> nested object filters\n * - $hasVector -> vector existence check\n * - $datetime -> RFC 3339 datetime range\n * - $null -> is_null check\n * - $empty -> is_empty check\n */\nexport class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {\n protected override isLogicalOperator(key: string): key is LogicalOperator {\n return super.isLogicalOperator(key) || key === '$hasId' || key === '$hasVector';\n }\n\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or', '$not'],\n array: ['$in', '$nin', '$all'],\n regex: ['$regex'],\n element: ['$exists'],\n custom: ['$count', '$geo', '$nested', '$datetime', '$null', '$empty', '$hasId', '$hasVector'],\n };\n }\n\n protected override isOperator(key: string): key is any {\n // $not can be both a logical operator and a field-level operator\n // When used at field level like { field: { $not: { $gt: 5 } } }, treat it as an operator\n return super.isOperator(key) || key === '$not';\n }\n\n translate(filter?: QdrantVectorFilter): QdrantVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private createCondition(type: string, value: any, fieldKey?: string) {\n const condition = { [type]: value };\n return fieldKey ? { key: fieldKey, ...condition } : condition;\n }\n\n private translateNode(node: QdrantVectorFilter, isNested: boolean = false, fieldKey?: string): any {\n if (!this.isEmpty(node) && !!node && typeof node === 'object' && 'must' in node) {\n return node;\n }\n\n if (this.isPrimitive(node)) {\n if (node === null) {\n return { is_null: { key: fieldKey } };\n }\n return this.createCondition('match', { value: this.normalizeComparisonValue(node) }, fieldKey);\n }\n\n if (this.isRegex(node)) {\n throw new Error('Direct regex pattern format is not supported in Qdrant');\n }\n\n if (Array.isArray(node)) {\n return node.length === 0\n ? { is_empty: { key: fieldKey } }\n : this.createCondition('match', { any: this.normalizeArrayValues(node) }, fieldKey);\n }\n\n const entries = Object.entries(node as Record<string, any>);\n\n // Handle logical operators first (but not $not when we have a fieldKey - that's handled as a field operator)\n const logicalResult = this.handleLogicalOperators(entries, isNested, fieldKey);\n if (logicalResult) {\n return logicalResult;\n }\n\n // Handle field conditions\n const { conditions, range, matchCondition } = this.handleFieldConditions(entries, fieldKey);\n\n if (Object.keys(range).length > 0) {\n conditions.push({ key: fieldKey, range });\n }\n\n if (matchCondition) {\n conditions.push({ key: fieldKey, match: matchCondition });\n }\n\n return this.buildFinalConditions(conditions, isNested);\n }\n\n private buildFinalConditions(conditions: any[], isNested: boolean): any {\n if (conditions.length === 0) {\n return {};\n } else if (conditions.length === 1 && isNested) {\n return conditions[0];\n } else {\n return { must: conditions };\n }\n }\n\n private handleLogicalOperators(entries: [string, any][], isNested: boolean, fieldKey?: string): any | null {\n const firstKey = entries[0]?.[0];\n\n // When we have a fieldKey and see $not, it's a field-level $not operator, not a logical operator\n // Let handleFieldConditions handle it via the _specialNot path\n if (firstKey === '$not' && fieldKey) {\n return null;\n }\n\n if (firstKey && this.isLogicalOperator(firstKey) && !this.isCustomOperator(firstKey)) {\n const [key, value] = entries[0]!;\n const qdrantOp = this.getQdrantLogicalOp(key);\n return {\n [qdrantOp]: Array.isArray(value)\n ? value.map(v => this.translateNode(v, true))\n : [this.translateNode(value, true)],\n };\n }\n\n if (\n entries.length > 1 &&\n !isNested &&\n entries.every(([key]) => !this.isOperator(key) && !this.isCustomOperator(key))\n ) {\n return {\n must: entries.map(([key, value]) => this.translateNode(value, true, key)),\n };\n }\n\n return null;\n }\n\n private handleFieldConditions(\n entries: [string, any][],\n fieldKey?: string,\n ): { conditions: any[]; range: Record<string, any>; matchCondition: Record<string, any> | null } {\n const conditions = [];\n let range: Record<string, any> = {};\n let matchCondition: Record<string, any> | null = null;\n\n for (const [key, value] of entries) {\n if (this.isCustomOperator(key)) {\n const customOp = this.translateCustomOperator(key, value, fieldKey);\n conditions.push(customOp);\n } else if (this.isOperator(key)) {\n const opResult = this.translateOperatorValue(key, value);\n\n // Handle special markers for operators that need custom handling\n if (opResult._specialNull) {\n // $eq: null -> use is_null\n conditions.push({ is_null: { key: fieldKey } });\n } else if (opResult._specialNotNull) {\n // $ne: null -> use must_not with is_null\n conditions.push({ must_not: [{ is_null: { key: fieldKey } }] });\n } else if (opResult._specialNe) {\n // $ne: value -> use must_not with match\n conditions.push({\n must_not: [{ key: fieldKey, match: { value: opResult._specialNe } }],\n });\n } else if (opResult._specialNin) {\n // $nin: [values] -> use must_not with match any\n conditions.push({\n must_not: [{ key: fieldKey, match: { any: opResult._specialNin } }],\n });\n } else if (opResult._specialAll) {\n // $all: [values] -> create multiple match conditions joined with must\n for (const val of opResult._specialAll) {\n conditions.push({ key: fieldKey, match: { value: val } });\n }\n } else if (opResult._specialExists) {\n // $exists: true -> field must not be null or empty\n conditions.push({\n must_not: [{ is_null: { key: fieldKey } }, { is_empty: { key: fieldKey } }],\n });\n } else if (opResult._specialNotExists) {\n // $exists: false -> field must be null or empty\n conditions.push({\n should: [{ is_null: { key: fieldKey } }, { is_empty: { key: fieldKey } }],\n });\n } else if (opResult._specialNot) {\n // $not: { operator: value } -> translate inner condition and wrap in must_not\n const innerResult = this.translateNode(opResult._specialNot, true, fieldKey);\n conditions.push({ must_not: [innerResult] });\n } else if (opResult.range) {\n Object.assign(range, opResult.range);\n } else {\n matchCondition = opResult;\n }\n } else {\n const nestedKey = fieldKey ? `${fieldKey}.${key}` : key;\n const nestedCondition = this.translateNode(value, true, nestedKey);\n\n if (nestedCondition.must) {\n conditions.push(...nestedCondition.must);\n } else if (!this.isEmpty(nestedCondition)) {\n conditions.push(nestedCondition);\n }\n }\n }\n\n return { conditions, range, matchCondition };\n }\n\n private translateCustomOperator(op: string, value: any, fieldKey?: string): any {\n switch (op) {\n case '$count':\n const countConditions = Object.entries(value).reduce(\n (acc, [k, v]) => ({\n ...acc,\n [k.replace('$', '')]: v,\n }),\n {},\n );\n return { key: fieldKey, values_count: countConditions };\n case '$geo':\n const geoOp = this.translateGeoFilter(value.type, value);\n return { key: fieldKey, ...geoOp };\n case '$hasId':\n return { has_id: Array.isArray(value) ? value : [value] };\n case '$nested':\n return {\n nested: {\n key: fieldKey,\n filter: this.translateNode(value),\n },\n };\n case '$hasVector':\n return { has_vector: value };\n case '$datetime':\n return {\n key: fieldKey,\n range: this.normalizeDatetimeRange(value.range),\n };\n case '$null':\n return { is_null: { key: fieldKey } };\n case '$empty':\n return { is_empty: { key: fieldKey } };\n default:\n throw new Error(`Unsupported custom operator: ${op}`);\n }\n }\n\n private getQdrantLogicalOp(op: string): string {\n switch (op) {\n case '$and':\n return 'must';\n case '$or':\n return 'should';\n case '$not':\n return 'must_not';\n default:\n throw new Error(`Unsupported logical operator: ${op}`);\n }\n }\n\n private translateOperatorValue(operator: string, value: any): any {\n const normalizedValue = this.normalizeComparisonValue(value);\n\n switch (operator) {\n case '$eq':\n // Handle null comparison: use is_null instead of match\n if (value === null) {\n return { _specialNull: true };\n }\n return { value: normalizedValue };\n case '$ne':\n // Handle null comparison: for \"not null\", we need is_null wrapped in must_not\n if (value === null) {\n return { _specialNotNull: true };\n }\n // For $ne with non-null values, we need to use must_not with match\n return { _specialNe: normalizedValue };\n case '$gt':\n return { range: { gt: normalizedValue } };\n case '$gte':\n return { range: { gte: normalizedValue } };\n case '$lt':\n return { range: { lt: normalizedValue } };\n case '$lte':\n return { range: { lte: normalizedValue } };\n case '$in':\n return { any: this.normalizeArrayValues(value) };\n case '$nin':\n // Similar to $ne, $nin should use must_not\n return { _specialNin: this.normalizeArrayValues(value) };\n case '$regex':\n return { text: value };\n case '$all':\n // For $all operator, all values must be present in the array\n // Qdrant doesn't have native $all, but we can use must with multiple match conditions\n return { _specialAll: this.normalizeArrayValues(value) };\n case '$exists':\n // $exists: true means field must not be null/empty\n // $exists: false means field must be null or empty\n return value ? { _specialExists: true } : { _specialNotExists: true };\n case '$not':\n // $not wraps another operator\n return { _specialNot: value };\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n }\n\n private translateGeoFilter(type: string, value: any): any {\n switch (type) {\n case 'box':\n return {\n geo_bounding_box: {\n top_left: value.top_left,\n bottom_right: value.bottom_right,\n },\n };\n case 'radius':\n return {\n geo_radius: {\n center: value.center,\n radius: value.radius,\n },\n };\n case 'polygon':\n return {\n geo_polygon: {\n exterior: value.exterior,\n interiors: value.interiors,\n },\n };\n default:\n throw new Error(`Unsupported geo filter type: ${type}`);\n }\n }\n\n private normalizeDatetimeRange(value: any): any {\n const range: Record<string, string> = {};\n for (const [op, val] of Object.entries(value)) {\n if (val instanceof Date) {\n range[op] = val.toISOString();\n } else if (typeof val === 'string') {\n // Assume string is already in proper format\n range[op] = val;\n }\n }\n return range;\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector, validateUpsertInput } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { QdrantClient } from '@qdrant/js-client-rest';\nimport type { QdrantClientParams, Schemas } from '@qdrant/js-client-rest';\n\nimport { QdrantFilterTranslator } from './filter';\nimport type { QdrantVectorFilter } from './filter';\n\nconst BATCH_SIZE = 256;\nconst DISTANCE_MAPPING: Record<string, Schemas['Distance']> = {\n cosine: 'Cosine',\n euclidean: 'Euclid',\n dotproduct: 'Dot',\n};\n\n/**\n * Configuration for a named vector space in Qdrant.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\nexport interface NamedVectorConfig {\n /** The dimension (size) of vectors in this space. */\n size: number;\n /** The distance metric for similarity search. */\n distance: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\n/**\n * Query parameters for Qdrant vector store.\n * Extends the base QueryVectorParams with Qdrant-specific options.\n */\nexport interface QdrantQueryVectorParams extends QueryVectorParams<QdrantVectorFilter> {\n /**\n * Name of the vector field to query against when using named vectors.\n * Use this when your collection has multiple named vector fields.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\n using?: string;\n}\n\n/**\n * Parameters for creating a Qdrant index/collection.\n * Extends the base CreateIndexParams with support for named vectors.\n */\nexport interface QdrantCreateIndexParams extends CreateIndexParams {\n /**\n * Configuration for named vector spaces.\n * When provided, creates a collection with multiple named vector fields.\n * Each key is the vector name, and the value defines its configuration.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n *\n * @example\n * ```ts\n * namedVectors: {\n * text: { size: 768, distance: 'cosine' },\n * image: { size: 512, distance: 'euclidean' },\n * }\n * ```\n */\n namedVectors?: Record<string, NamedVectorConfig>;\n}\n\n/**\n * Parameters for upserting vectors into Qdrant.\n * Extends the base UpsertVectorParams with support for named vectors.\n */\nexport interface QdrantUpsertVectorParams extends UpsertVectorParams {\n /**\n * Name of the vector space to upsert into when using named vectors.\n * Required when the collection was created with namedVectors.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\n vectorName?: string;\n}\n\n/**\n * Supported payload schema types for Qdrant payload indexes.\n * These correspond to Qdrant's native payload indexing types.\n * @see https://qdrant.tech/documentation/concepts/indexing/#payload-index\n */\nexport type PayloadSchemaType = 'keyword' | 'integer' | 'float' | 'geo' | 'text' | 'bool' | 'datetime' | 'uuid';\n\n/**\n * Parameters for creating a payload index on a Qdrant collection.\n */\nexport interface CreatePayloadIndexParams {\n /** The name of the collection (index) to create the payload index on. */\n indexName: string;\n /** The name of the payload field to index. */\n fieldName: string;\n /** The schema type for the payload field. */\n fieldSchema: PayloadSchemaType;\n /** Whether to wait for the operation to complete. Defaults to true. */\n wait?: boolean;\n}\n\n/**\n * Parameters for deleting a payload index from a Qdrant collection.\n */\nexport interface DeletePayloadIndexParams {\n /** The name of the collection (index) to delete the payload index from. */\n indexName: string;\n /** The name of the payload field index to delete. */\n fieldName: string;\n /** Whether to wait for the operation to complete. Defaults to true. */\n wait?: boolean;\n}\n\n// Qdrant accepts simple, hyphenated, braced, and `urn:uuid:` UUID forms.\nconst QDRANT_UUID_REGEX =\n /^(?:urn:uuid:)?(?:[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}|\\{[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}\\})$/i;\nconst QDRANT_MAX_POINT_ID = 18446744073709551615n;\n\nfunction isValidQdrantPointId(id: string): boolean {\n if (/^\\d+$/.test(id)) return BigInt(id) <= QDRANT_MAX_POINT_ID;\n return QDRANT_UUID_REGEX.test(id);\n}\n\nexport class QdrantVector extends MastraVector {\n protected client: QdrantClient;\n\n /**\n * Creates a new QdrantVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param url - The URL of the Qdrant server.\n * @param apiKey - The API key for Qdrant.\n * @param https - Whether to use HTTPS.\n */\n constructor({ id, ...qdrantParams }: QdrantClientParams & { id: string }) {\n super({ id });\n this.client = new QdrantClient(qdrantParams);\n }\n\n /**\n * Validates that a named vector exists in the collection.\n * @param indexName - The name of the collection to check.\n * @param vectorName - The name of the vector space to validate.\n * @throws Error if the vector name doesn't exist in the collection.\n */\n private async validateVectorName(indexName: string, vectorName: string): Promise<void> {\n const { config } = await this.client.getCollection(indexName);\n const vectorsConfig = config.params.vectors;\n const isNamedVectors = vectorsConfig && typeof vectorsConfig === 'object' && !('size' in vectorsConfig);\n\n if (!isNamedVectors || !(vectorName in vectorsConfig)) {\n throw new Error(`Vector name \"${vectorName}\" does not exist in collection \"${indexName}\"`);\n }\n }\n\n /**\n * Upserts vectors into the index.\n * @param indexName - The name of the index to upsert into.\n * @param vectors - Array of embedding vectors.\n * @param metadata - Optional metadata for each vector.\n * @param ids - Optional vector IDs (auto-generated if not provided).\n * @param vectorName - Optional name of the vector space when using named vectors.\n */\n async upsert({ indexName, vectors, metadata, ids, vectorName }: QdrantUpsertVectorParams): Promise<string[]> {\n // Validate input parameters\n validateUpsertInput('QDRANT', vectors, metadata, ids);\n const pointIds = ids ? ids.map(id => this.parsePointId(id)) : vectors.map(() => crypto.randomUUID());\n\n // Validate vector name if provided\n if (vectorName) {\n try {\n await this.validateVectorName(indexName, vectorName);\n } catch (validationError) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPSERT', 'INVALID_VECTOR_NAME'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, vectorName },\n },\n validationError,\n );\n }\n }\n\n const records = vectors.map((vector, i) => ({\n id: pointIds[i]!,\n vector: vectorName ? { [vectorName]: vector } : vector,\n payload: metadata?.[i] || {},\n }));\n\n try {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n points: batch,\n wait: true,\n });\n }\n\n return pointIds.map(String);\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length, ...(vectorName && { vectorName }) },\n },\n error,\n );\n }\n }\n\n /**\n * Creates a new index (collection) in Qdrant.\n * Supports both single vector and named vector configurations.\n *\n * @param indexName - The name of the collection to create.\n * @param dimension - Vector dimension (required for single vector mode).\n * @param metric - Distance metric (default: 'cosine').\n * @param namedVectors - Optional named vector configurations for multi-vector collections.\n *\n * @example\n * ```ts\n * // Single vector collection\n * await qdrant.createIndex({ indexName: 'docs', dimension: 768, metric: 'cosine' });\n *\n * // Named vectors collection\n * await qdrant.createIndex({\n * indexName: 'multi-modal',\n * dimension: 768, // Used as fallback, can be omitted with namedVectors\n * namedVectors: {\n * text: { size: 768, distance: 'cosine' },\n * image: { size: 512, distance: 'euclidean' },\n * },\n * });\n * ```\n */\n async createIndex({ indexName, dimension, metric = 'cosine', namedVectors }: QdrantCreateIndexParams): Promise<void> {\n try {\n if (namedVectors) {\n // Validate named vectors configuration\n if (Object.keys(namedVectors).length === 0) {\n throw new Error('namedVectors must contain at least one named vector configuration');\n }\n for (const [name, config] of Object.entries(namedVectors)) {\n if (!Number.isInteger(config.size) || config.size <= 0) {\n throw new Error(`Named vector \"${name}\": size must be a positive integer`);\n }\n if (!DISTANCE_MAPPING[config.distance]) {\n throw new Error(\n `Named vector \"${name}\": invalid distance \"${config.distance}\". Must be one of: cosine, euclidean, dotproduct`,\n );\n }\n }\n } else {\n // Validate single vector configuration\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (!DISTANCE_MAPPING[metric]) {\n throw new Error(`Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`);\n }\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_INDEX', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: {\n indexName,\n dimension,\n metric,\n ...(namedVectors && { namedVectorNames: Object.keys(namedVectors).join(', ') }),\n },\n },\n validationError,\n );\n }\n\n try {\n // Build vectors configuration\n if (namedVectors) {\n const namedVectorsConfig = Object.entries(namedVectors).reduce(\n (acc, [name, config]) => {\n acc[name] = {\n size: config.size,\n distance: DISTANCE_MAPPING[config.distance]!,\n };\n return acc;\n },\n {} as Record<string, { size: number; distance: Schemas['Distance'] }>,\n );\n\n await this.client.createCollection(indexName, {\n vectors: namedVectorsConfig,\n });\n } else {\n await this.client.createCollection(indexName, {\n vectors: {\n size: dimension,\n distance: DISTANCE_MAPPING[metric]!,\n },\n });\n }\n } catch (error: any) {\n const message = error?.message || error?.toString();\n // Qdrant typically returns 409 for existing collection\n if (error?.status === 409 || (typeof message === 'string' && message.toLowerCase().includes('exists'))) {\n if (!namedVectors) {\n // Fetch collection info and check dimension for single vector mode\n await this.validateExistingIndex(indexName, dimension, metric);\n } else {\n // For named vectors, just log and continue (validation is complex)\n this.logger.info(\n `Collection \"${indexName}\" already exists. Skipping validation for named vectors configuration.`,\n );\n }\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: QdrantVectorFilter) {\n const translator = new QdrantFilterTranslator();\n return translator.translate(filter);\n }\n\n /**\n * Queries the index for similar vectors.\n *\n * @param indexName - The name of the index to query.\n * @param queryVector - The query vector to find similar vectors for.\n * @param topK - Number of results to return (default: 10).\n * @param filter - Optional metadata filter.\n * @param includeVector - Whether to include vectors in results (default: false).\n * @param using - Name of the vector space to query when using named vectors.\n */\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n using,\n }: QdrantQueryVectorParams): Promise<QueryResult[]> {\n if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Qdrant queries. Metadata-only queries are not supported by this vector store.',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const translatedFilter = this.transformFilter(filter) ?? {};\n\n try {\n const results = (\n await this.client.query(indexName, {\n query: queryVector,\n limit: topK,\n filter: translatedFilter,\n with_payload: true,\n with_vector: includeVector,\n ...(using ? { using } : {}),\n })\n ).points;\n\n return results.map(match => {\n let vector: number[] = [];\n if (includeVector && match.vector != null) {\n if (Array.isArray(match.vector)) {\n // Single vector mode - already an array of numbers\n vector = match.vector as number[];\n } else if (typeof match.vector === 'object' && match.vector !== null) {\n // Named vectors mode - extract from the correct vector space\n const namedVectors = match.vector as Record<string, unknown>;\n\n // If `using` is specified, try to get that specific vector\n // Otherwise, find the first array in the object\n const sourceArray: unknown[] | undefined =\n using && Array.isArray(namedVectors[using])\n ? (namedVectors[using] as unknown[])\n : (Object.values(namedVectors).find(v => Array.isArray(v)) as unknown[] | undefined);\n\n if (sourceArray) {\n vector = sourceArray.filter((v): v is number => typeof v === 'number');\n }\n }\n }\n\n return {\n id: match.id as string,\n score: match.score || 0,\n metadata: match.payload as Record<string, any>,\n ...(includeVector && { vector }),\n };\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK, ...(using && { using }) },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const response = await this.client.getCollections();\n return response.collections.map(collection => collection.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const { config, points_count } = await this.client.getCollection(indexName);\n\n const distance = config.params.vectors?.distance as Schemas['Distance'];\n return {\n dimension: config.params.vectors?.size as number,\n count: points_count || 0,\n metric: (Object.keys(DISTANCE_MAPPING) as (keyof typeof DISTANCE_MAPPING)[]).find(\n key => DISTANCE_MAPPING[key] === distance,\n ) as IndexStats['metric'],\n };\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection(indexName);\n } catch (error: any) {\n // If the collection doesn't exist, treat it as a no-op (already deleted)\n const errorMessage = error?.message || error?.toString() || '';\n if (\n error?.status === 404 ||\n errorMessage.toLowerCase().includes('not found') ||\n errorMessage.toLowerCase().includes('not exist')\n ) {\n this.logger.info(`Collection ${indexName} does not exist, treating as already deleted`);\n return;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID or multiple vectors matching a filter.\n * @param indexName - The name of the index containing the vector(s).\n * @param id - The ID of the vector to update (mutually exclusive with filter).\n * @param filter - Filter to match multiple vectors to update (mutually exclusive with id).\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<QdrantVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (id && filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!id && !filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'NO_TARGET'),\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\n text: 'No updates provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: {\n indexName,\n ...(id && { id }),\n },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'EMPTY_FILTER'),\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n if (id) {\n // Update single vector by ID\n const pointId = this.parsePointId(id);\n\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n await this.client.setPayload(indexName, { payload: update.metadata, points: [pointId] });\n return;\n }\n\n // Handle vector-only update\n if (update.vector && !update.metadata) {\n await this.client.updateVectors(indexName, {\n points: [\n {\n id: pointId,\n vector: update.vector,\n },\n ],\n });\n return;\n }\n\n // Handle both vector and metadata update\n if (update.vector && update.metadata) {\n const point = {\n id: pointId,\n vector: update.vector,\n payload: update.metadata,\n };\n\n await this.client.upsert(indexName, {\n points: [point],\n });\n return;\n }\n } else if (filter) {\n // Update multiple vectors matching filter\n const translatedFilter = this.transformFilter(filter);\n\n // First, scroll through all matching points to get their IDs\n const matchingPoints: Array<{ id: string | number; vector?: number[] }> = [];\n let offset: string | number | undefined = undefined;\n\n do {\n const scrollResult = await this.client.scroll(indexName, {\n filter: translatedFilter,\n limit: 100,\n offset,\n with_payload: false,\n with_vector: !update.vector, // Only fetch vectors if not updating them\n });\n\n matchingPoints.push(\n ...scrollResult.points.map(point => ({\n id: point.id,\n vector: Array.isArray(point.vector) ? (point.vector as number[]) : undefined,\n })),\n );\n\n const nextOffset = scrollResult.next_page_offset;\n offset = typeof nextOffset === 'string' || typeof nextOffset === 'number' ? nextOffset : undefined;\n } while (offset !== undefined);\n\n if (matchingPoints.length === 0) {\n // No vectors to update - this is not an error\n return;\n }\n\n const pointIds = matchingPoints.map(p => p.id);\n\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n await this.client.setPayload(indexName, { payload: update.metadata, points: pointIds });\n return;\n }\n\n // Handle vector-only or both updates\n if (update.vector) {\n // For vector updates with filter, we need to upsert each point\n const points = matchingPoints.map(p => ({\n id: p.id,\n vector: update.vector!,\n payload: update.metadata || {},\n }));\n\n // Batch upsert\n for (let i = 0; i < points.length; i += BATCH_SIZE) {\n const batch = points.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n points: batch,\n wait: true,\n });\n }\n return;\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n ...(filter && { filter: JSON.stringify(filter) }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n // Parse the ID - Qdrant supports both string and numeric IDs\n const pointId = this.parsePointId(id);\n\n // Use the Qdrant client to delete the point from the collection\n await this.client.delete(indexName, {\n points: [pointId],\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.\n *\n * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format\n * before sending them to the Qdrant client API.\n *\n * @param id - The ID string to parse\n * @returns The parsed ID as either a number (if string contains only digits) or the original string\n *\n * @example\n * // Numeric ID strings are converted to numbers\n * parsePointId(\"123\") => 123\n * parsePointId(\"42\") => 42\n * parsePointId(\"0\") => 0\n *\n * // String IDs containing any non-digit characters remain as strings\n * parsePointId(\"doc-123\") => \"doc-123\"\n * parsePointId(\"user_42\") => \"user_42\"\n * parsePointId(\"abc123\") => \"abc123\"\n * parsePointId(\"123abc\") => \"123abc\"\n * parsePointId(\"\") => \"\"\n * parsePointId(\"uuid-5678-xyz\") => \"uuid-5678-xyz\"\n *\n * @remarks\n * - This conversion is important because Qdrant treats numeric and string IDs differently\n * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)\n * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions\n * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids\n */\n private parsePointId(id: string): string | number {\n // Try to parse as number if it looks like one\n if (/^\\d+$/.test(id)) {\n return parseInt(id, 10);\n }\n return id;\n }\n\n /**\n * Deletes multiple vectors by IDs or filter.\n * @param indexName - The name of the index containing the vectors.\n * @param ids - Array of vector IDs to delete (mutually exclusive with filter).\n * @param filter - Filter to match vectors to delete (mutually exclusive with ids).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if both ids and filter are provided, or if neither is provided.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<QdrantVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'NO_TARGET'),\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate ids array is not empty\n if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'EMPTY_IDS'),\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'EMPTY_FILTER'),\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n if (ids) {\n // Qdrant rejects the whole batch with a 400 if any ID is not a uint64 or UUID,\n // so surface malformed IDs as a user error instead of letting nothing be deleted.\n const invalidIds = ids.filter(id => !isValidQdrantPointId(id));\n if (invalidIds.length > 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'INVALID_IDS'),\n text: `Invalid Qdrant point IDs (must be unsigned integers or UUIDs): ${invalidIds.join(', ')}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, invalidIds: invalidIds.join(', ') },\n });\n }\n await this.client.delete(indexName, {\n points: ids.map(id => this.parsePointId(id)),\n wait: true,\n });\n } else if (filter) {\n // Delete by filter\n const translatedFilter = this.transformFilter(filter) ?? {};\n await this.client.delete(indexName, {\n filter: translatedFilter as any,\n wait: true,\n });\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Creates a payload index on a Qdrant collection to enable efficient filtering on metadata fields.\n *\n * This is required for Qdrant Cloud and any Qdrant instance with `strict_mode_config = true`,\n * where metadata (payload) fields must be explicitly indexed before they can be used for filtering.\n *\n * @param params - The parameters for creating the payload index.\n * @param params.indexName - The name of the collection (index) to create the payload index on.\n * @param params.fieldName - The name of the payload field to index.\n * @param params.fieldSchema - The schema type for the field (e.g., 'keyword', 'integer', 'text').\n * @param params.wait - Whether to wait for the operation to complete. Defaults to true.\n * @returns A promise that resolves when the index is created (idempotent if index already exists).\n * @throws Will throw a MastraError if arguments are invalid or if the operation fails.\n *\n * @example\n * ```ts\n * // Create a keyword index for filtering by source\n * await qdrant.createPayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'source',\n * fieldSchema: 'keyword',\n * });\n *\n * // Create an integer index for numeric filtering\n * await qdrant.createPayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'price',\n * fieldSchema: 'integer',\n * });\n * ```\n *\n * @see https://qdrant.tech/documentation/concepts/indexing/#payload-index\n */\n async createPayloadIndex({\n indexName,\n fieldName,\n fieldSchema,\n wait = true,\n }: CreatePayloadIndexParams): Promise<void> {\n // Validate inputs\n const validSchemas: PayloadSchemaType[] = [\n 'keyword',\n 'integer',\n 'float',\n 'geo',\n 'text',\n 'bool',\n 'datetime',\n 'uuid',\n ];\n\n if (!indexName || typeof indexName !== 'string' || indexName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'indexName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n if (!fieldName || typeof fieldName !== 'string' || fieldName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'fieldName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n if (!validSchemas.includes(fieldSchema)) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: `fieldSchema must be one of: ${validSchemas.join(', ')}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n try {\n await this.client.createPayloadIndex(indexName, {\n field_name: fieldName,\n field_schema: fieldSchema,\n wait,\n });\n } catch (error: any) {\n const message = error?.message || error?.toString() || '';\n // Qdrant returns 409 or \"exists\" message if index already exists - treat as idempotent success\n if (error?.status === 409 || message.toLowerCase().includes('exists')) {\n this.logger.info(`Payload index for field \"${fieldName}\" already exists on collection \"${indexName}\"`);\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, fieldName, fieldSchema },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a payload index from a Qdrant collection.\n *\n * @param params - The parameters for deleting the payload index.\n * @param params.indexName - The name of the collection (index) to delete the payload index from.\n * @param params.fieldName - The name of the payload field index to delete.\n * @param params.wait - Whether to wait for the operation to complete. Defaults to true.\n * @returns A promise that resolves when the index is deleted (idempotent if index doesn't exist).\n * @throws Will throw a MastraError if the operation fails.\n *\n * @example\n * ```ts\n * await qdrant.deletePayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'source',\n * });\n * ```\n */\n async deletePayloadIndex({ indexName, fieldName, wait = true }: DeletePayloadIndexParams): Promise<void> {\n // Validate inputs\n if (!indexName || typeof indexName !== 'string' || indexName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'indexName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName },\n });\n }\n\n if (!fieldName || typeof fieldName !== 'string' || fieldName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'fieldName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName },\n });\n }\n\n try {\n await this.client.deletePayloadIndex(indexName, fieldName, { wait });\n } catch (error: any) {\n const message = error?.message || error?.toString() || '';\n // If index doesn't exist, treat as idempotent success (already deleted)\n if (\n error?.status === 404 ||\n message.toLowerCase().includes('not found') ||\n message.toLowerCase().includes('not exist')\n ) {\n this.logger.info(`Payload index for field \"${fieldName}\" does not exist on collection \"${indexName}\"`);\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, fieldName },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Qdrant Vector.\n */\nexport const QDRANT_PROMPT = `When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwHA,IAAa,yBAAb,cAA4CA,2BAAAA,qBAAyC;CACnF,kBAAqC,KAAqC;EACxE,OAAO,MAAM,kBAAkB,GAAG,KAAK,QAAQ,YAAY,QAAQ;CACrE;CAEA,wBAA4D;EAC1D,OAAO;GACL,GAAGA,2BAAAA,qBAAqB;GACxB,SAAS;IAAC;IAAQ;IAAO;GAAM;GAC/B,OAAO;IAAC;IAAO;IAAQ;GAAM;GAC7B,OAAO,CAAC,QA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AE;KAAW;IAAU;GAClC,GACA,KACF;EACF;CACF;AACF;;;;;;;ACl/BA,MAAa,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseFilterTranslator","MastraVector","QdrantClient","MastraError","createVectorErrorId","ErrorDomain","ErrorCategory"],"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n LogicalOperator,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch'> & {\n /**\n * $count: Filter by array length or value count.\n * Example: { tags: { $count: { gt: 2 } } }\n */\n $count: {\n $gt?: number;\n $gte?: number;\n $lt?: number;\n $lte?: number;\n $eq?: number;\n };\n\n /**\n * $geo: Geospatial filter.\n * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }\n */\n $geo: {\n type: string;\n [key: string]: any;\n };\n\n /**\n * $hasId: Filter by point IDs.\n * Allowed at root level.\n * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }\n */\n $hasId: string | string[];\n\n /**\n * $nested: Nested object filter.\n * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }\n */\n $nested: {\n // Additional properties depend on the nested object structure\n [key: string]: any;\n };\n\n /**\n * $hasVector: Filter by vector existence or field.\n * Allowed at root level.\n * Example: { $hasVector: true } or { $hasVector: 'vector_field' }\n */\n $hasVector: boolean | string;\n\n /**\n * $datetime: RFC 3339 datetime range.\n * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }\n */\n $datetime: {\n key?: string;\n range?: {\n gt?: Date | string;\n gte?: Date | string;\n lt?: Date | string;\n lte?: Date | string;\n eq?: Date | string;\n };\n };\n\n /**\n * $null: Check if a field is null.\n * Example: { metadata: { $null: true } }\n */\n $null: boolean;\n\n /**\n * $empty: Check if an array or object field is empty.\n * Example: { tags: { $empty: true } }\n */\n $empty: boolean;\n};\n\ntype QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype QdrantBlacklistedRootOperators =\n | BlacklistedRootOperators\n | '$count'\n | '$geo'\n | '$nested'\n | '$datetime'\n | '$null'\n | '$empty';\n\nexport type QdrantVectorFilter = VectorFilter<\n keyof QdrantOperatorValueMap,\n QdrantOperatorValueMap,\n QdrantLogicalOperatorValueMap,\n QdrantBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters to Qdrant compatible filters.\n *\n * Key transformations:\n * - $and -> must\n * - $or -> should\n * - $not -> must_not\n * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }\n *\n * Custom operators (Qdrant-specific):\n * - $count -> values_count (array length/value count)\n * - $geo -> geo filters (box, radius, polygon)\n * - $hasId -> has_id filter\n * - $nested -> nested object filters\n * - $hasVector -> vector existence check\n * - $datetime -> RFC 3339 datetime range\n * - $null -> is_null check\n * - $empty -> is_empty check\n */\nexport class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {\n protected override isLogicalOperator(key: string): key is LogicalOperator {\n return super.isLogicalOperator(key) || key === '$hasId' || key === '$hasVector';\n }\n\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or', '$not'],\n array: ['$in', '$nin', '$all'],\n regex: ['$regex'],\n element: ['$exists'],\n custom: ['$count', '$geo', '$nested', '$datetime', '$null', '$empty', '$hasId', '$hasVector'],\n };\n }\n\n protected override isOperator(key: string): key is any {\n // $not can be both a logical operator and a field-level operator\n // When used at field level like { field: { $not: { $gt: 5 } } }, treat it as an operator\n return super.isOperator(key) || key === '$not';\n }\n\n translate(filter?: QdrantVectorFilter): QdrantVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private createCondition(type: string, value: any, fieldKey?: string) {\n const condition = { [type]: value };\n return fieldKey ? { key: fieldKey, ...condition } : condition;\n }\n\n private translateNode(node: QdrantVectorFilter, isNested: boolean = false, fieldKey?: string): any {\n if (!this.isEmpty(node) && !!node && typeof node === 'object' && 'must' in node) {\n return node;\n }\n\n if (this.isPrimitive(node)) {\n if (node === null) {\n return { is_null: { key: fieldKey } };\n }\n return this.createCondition('match', { value: this.normalizeComparisonValue(node) }, fieldKey);\n }\n\n if (this.isRegex(node)) {\n throw new Error('Direct regex pattern format is not supported in Qdrant');\n }\n\n if (Array.isArray(node)) {\n return node.length === 0\n ? { is_empty: { key: fieldKey } }\n : this.createCondition('match', { any: this.normalizeArrayValues(node) }, fieldKey);\n }\n\n const entries = Object.entries(node as Record<string, any>);\n\n // Handle logical operators first (but not $not when we have a fieldKey - that's handled as a field operator)\n const logicalResult = this.handleLogicalOperators(entries, isNested, fieldKey);\n if (logicalResult) {\n return logicalResult;\n }\n\n // Handle field conditions\n const { conditions, range, matchCondition } = this.handleFieldConditions(entries, fieldKey);\n\n if (Object.keys(range).length > 0) {\n conditions.push({ key: fieldKey, range });\n }\n\n if (matchCondition) {\n conditions.push({ key: fieldKey, match: matchCondition });\n }\n\n return this.buildFinalConditions(conditions, isNested);\n }\n\n private buildFinalConditions(conditions: any[], isNested: boolean): any {\n if (conditions.length === 0) {\n return {};\n } else if (conditions.length === 1 && isNested) {\n return conditions[0];\n } else {\n return { must: conditions };\n }\n }\n\n private handleLogicalOperators(entries: [string, any][], isNested: boolean, fieldKey?: string): any | null {\n const firstKey = entries[0]?.[0];\n\n // When we have a fieldKey and see $not, it's a field-level $not operator, not a logical operator\n // Let handleFieldConditions handle it via the _specialNot path\n if (firstKey === '$not' && fieldKey) {\n return null;\n }\n\n if (firstKey && this.isLogicalOperator(firstKey) && !this.isCustomOperator(firstKey)) {\n const [key, value] = entries[0]!;\n const qdrantOp = this.getQdrantLogicalOp(key);\n return {\n [qdrantOp]: Array.isArray(value)\n ? value.map(v => this.translateNode(v, true))\n : [this.translateNode(value, true)],\n };\n }\n\n if (\n entries.length > 1 &&\n !isNested &&\n entries.every(([key]) => !this.isOperator(key) && !this.isCustomOperator(key))\n ) {\n return {\n must: entries.map(([key, value]) => this.translateNode(value, true, key)),\n };\n }\n\n return null;\n }\n\n private handleFieldConditions(\n entries: [string, any][],\n fieldKey?: string,\n ): { conditions: any[]; range: Record<string, any>; matchCondition: Record<string, any> | null } {\n const conditions = [];\n let range: Record<string, any> = {};\n let matchCondition: Record<string, any> | null = null;\n\n for (const [key, value] of entries) {\n if (this.isCustomOperator(key)) {\n const customOp = this.translateCustomOperator(key, value, fieldKey);\n conditions.push(customOp);\n } else if (this.isOperator(key)) {\n const opResult = this.translateOperatorValue(key, value);\n\n // Handle special markers for operators that need custom handling\n if (opResult._specialNull) {\n // $eq: null -> use is_null\n conditions.push({ is_null: { key: fieldKey } });\n } else if (opResult._specialNotNull) {\n // $ne: null -> use must_not with is_null\n conditions.push({ must_not: [{ is_null: { key: fieldKey } }] });\n } else if (opResult._specialNe) {\n // $ne: value -> use must_not with match\n conditions.push({\n must_not: [{ key: fieldKey, match: { value: opResult._specialNe } }],\n });\n } else if (opResult._specialNin) {\n // $nin: [values] -> use must_not with match any\n conditions.push({\n must_not: [{ key: fieldKey, match: { any: opResult._specialNin } }],\n });\n } else if (opResult._specialAll) {\n // $all: [values] -> create multiple match conditions joined with must\n for (const val of opResult._specialAll) {\n conditions.push({ key: fieldKey, match: { value: val } });\n }\n } else if (opResult._specialExists) {\n // $exists: true -> field must not be null or empty\n conditions.push({\n must_not: [{ is_null: { key: fieldKey } }, { is_empty: { key: fieldKey } }],\n });\n } else if (opResult._specialNotExists) {\n // $exists: false -> field must be null or empty\n conditions.push({\n should: [{ is_null: { key: fieldKey } }, { is_empty: { key: fieldKey } }],\n });\n } else if (opResult._specialNot) {\n // $not: { operator: value } -> translate inner condition and wrap in must_not\n const innerResult = this.translateNode(opResult._specialNot, true, fieldKey);\n conditions.push({ must_not: [innerResult] });\n } else if (opResult.range) {\n Object.assign(range, opResult.range);\n } else {\n matchCondition = opResult;\n }\n } else {\n const nestedKey = fieldKey ? `${fieldKey}.${key}` : key;\n const nestedCondition = this.translateNode(value, true, nestedKey);\n\n if (nestedCondition.must) {\n conditions.push(...nestedCondition.must);\n } else if (!this.isEmpty(nestedCondition)) {\n conditions.push(nestedCondition);\n }\n }\n }\n\n return { conditions, range, matchCondition };\n }\n\n private translateCustomOperator(op: string, value: any, fieldKey?: string): any {\n switch (op) {\n case '$count':\n const countConditions = Object.entries(value).reduce(\n (acc, [k, v]) => ({\n ...acc,\n [k.replace('$', '')]: v,\n }),\n {},\n );\n return { key: fieldKey, values_count: countConditions };\n case '$geo':\n const geoOp = this.translateGeoFilter(value.type, value);\n return { key: fieldKey, ...geoOp };\n case '$hasId':\n return { has_id: Array.isArray(value) ? value : [value] };\n case '$nested':\n return {\n nested: {\n key: fieldKey,\n filter: this.translateNode(value),\n },\n };\n case '$hasVector':\n return { has_vector: value };\n case '$datetime':\n return {\n key: fieldKey,\n range: this.normalizeDatetimeRange(value.range),\n };\n case '$null':\n return { is_null: { key: fieldKey } };\n case '$empty':\n return { is_empty: { key: fieldKey } };\n default:\n throw new Error(`Unsupported custom operator: ${op}`);\n }\n }\n\n private getQdrantLogicalOp(op: string): string {\n switch (op) {\n case '$and':\n return 'must';\n case '$or':\n return 'should';\n case '$not':\n return 'must_not';\n default:\n throw new Error(`Unsupported logical operator: ${op}`);\n }\n }\n\n private translateOperatorValue(operator: string, value: any): any {\n const normalizedValue = this.normalizeComparisonValue(value);\n\n switch (operator) {\n case '$eq':\n // Handle null comparison: use is_null instead of match\n if (value === null) {\n return { _specialNull: true };\n }\n return { value: normalizedValue };\n case '$ne':\n // Handle null comparison: for \"not null\", we need is_null wrapped in must_not\n if (value === null) {\n return { _specialNotNull: true };\n }\n // For $ne with non-null values, we need to use must_not with match\n return { _specialNe: normalizedValue };\n case '$gt':\n return { range: { gt: normalizedValue } };\n case '$gte':\n return { range: { gte: normalizedValue } };\n case '$lt':\n return { range: { lt: normalizedValue } };\n case '$lte':\n return { range: { lte: normalizedValue } };\n case '$in':\n return { any: this.normalizeArrayValues(value) };\n case '$nin':\n // Similar to $ne, $nin should use must_not\n return { _specialNin: this.normalizeArrayValues(value) };\n case '$regex':\n return { text: value };\n case '$all':\n // For $all operator, all values must be present in the array\n // Qdrant doesn't have native $all, but we can use must with multiple match conditions\n return { _specialAll: this.normalizeArrayValues(value) };\n case '$exists':\n // $exists: true means field must not be null/empty\n // $exists: false means field must be null or empty\n return value ? { _specialExists: true } : { _specialNotExists: true };\n case '$not':\n // $not wraps another operator\n return { _specialNot: value };\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n }\n\n private translateGeoFilter(type: string, value: any): any {\n switch (type) {\n case 'box':\n return {\n geo_bounding_box: {\n top_left: value.top_left,\n bottom_right: value.bottom_right,\n },\n };\n case 'radius':\n return {\n geo_radius: {\n center: value.center,\n radius: value.radius,\n },\n };\n case 'polygon':\n return {\n geo_polygon: {\n exterior: value.exterior,\n interiors: value.interiors,\n },\n };\n default:\n throw new Error(`Unsupported geo filter type: ${type}`);\n }\n }\n\n private normalizeDatetimeRange(value: any): any {\n const range: Record<string, string> = {};\n for (const [op, val] of Object.entries(value)) {\n if (val instanceof Date) {\n range[op] = val.toISOString();\n } else if (typeof val === 'string') {\n // Assume string is already in proper format\n range[op] = val;\n }\n }\n return range;\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector, validateUpsertInput } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { QdrantClient } from '@qdrant/js-client-rest';\nimport type { QdrantClientParams, Schemas } from '@qdrant/js-client-rest';\n\nimport { QdrantFilterTranslator } from './filter';\nimport type { QdrantVectorFilter } from './filter';\n\nconst BATCH_SIZE = 256;\nconst DISTANCE_MAPPING: Record<string, Schemas['Distance']> = {\n cosine: 'Cosine',\n euclidean: 'Euclid',\n dotproduct: 'Dot',\n};\n\n/**\n * Configuration for a named vector space in Qdrant.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\nexport interface NamedVectorConfig {\n /** The dimension (size) of vectors in this space. */\n size: number;\n /** The distance metric for similarity search. */\n distance: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\n/**\n * Query parameters for Qdrant vector store.\n * Extends the base QueryVectorParams with Qdrant-specific options.\n */\nexport interface QdrantQueryVectorParams extends QueryVectorParams<QdrantVectorFilter> {\n /**\n * Name of the vector field to query against when using named vectors.\n * Use this when your collection has multiple named vector fields.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\n using?: string;\n}\n\n/**\n * Parameters for creating a Qdrant index/collection.\n * Extends the base CreateIndexParams with support for named vectors.\n */\nexport interface QdrantCreateIndexParams extends CreateIndexParams {\n /**\n * Configuration for named vector spaces.\n * When provided, creates a collection with multiple named vector fields.\n * Each key is the vector name, and the value defines its configuration.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n *\n * @example\n * ```ts\n * namedVectors: {\n * text: { size: 768, distance: 'cosine' },\n * image: { size: 512, distance: 'euclidean' },\n * }\n * ```\n */\n namedVectors?: Record<string, NamedVectorConfig>;\n}\n\n/**\n * Parameters for upserting vectors into Qdrant.\n * Extends the base UpsertVectorParams with support for named vectors.\n */\nexport interface QdrantUpsertVectorParams extends UpsertVectorParams {\n /**\n * Name of the vector space to upsert into when using named vectors.\n * Required when the collection was created with namedVectors.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\n vectorName?: string;\n}\n\n/**\n * Supported payload schema types for Qdrant payload indexes.\n * These correspond to Qdrant's native payload indexing types.\n * @see https://qdrant.tech/documentation/concepts/indexing/#payload-index\n */\nexport type PayloadSchemaType = 'keyword' | 'integer' | 'float' | 'geo' | 'text' | 'bool' | 'datetime' | 'uuid';\n\n/**\n * Parameters for creating a payload index on a Qdrant collection.\n */\nexport interface CreatePayloadIndexParams {\n /** The name of the collection (index) to create the payload index on. */\n indexName: string;\n /** The name of the payload field to index. */\n fieldName: string;\n /** The schema type for the payload field. */\n fieldSchema: PayloadSchemaType;\n /** Whether to wait for the operation to complete. Defaults to true. */\n wait?: boolean;\n}\n\n/**\n * Parameters for deleting a payload index from a Qdrant collection.\n */\nexport interface DeletePayloadIndexParams {\n /** The name of the collection (index) to delete the payload index from. */\n indexName: string;\n /** The name of the payload field index to delete. */\n fieldName: string;\n /** Whether to wait for the operation to complete. Defaults to true. */\n wait?: boolean;\n}\n\n// Qdrant accepts simple, hyphenated, braced, and `urn:uuid:` UUID forms.\nconst QDRANT_UUID_REGEX =\n /^(?:urn:uuid:)?(?:[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}|\\{[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}\\})$/i;\nconst QDRANT_MAX_POINT_ID = 18446744073709551615n;\n\nfunction isValidQdrantPointId(id: string): boolean {\n if (/^\\d+$/.test(id)) return BigInt(id) <= QDRANT_MAX_POINT_ID;\n return QDRANT_UUID_REGEX.test(id);\n}\n\nexport class QdrantVector extends MastraVector {\n protected client: QdrantClient;\n\n /**\n * Creates a new QdrantVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param url - The URL of the Qdrant server.\n * @param apiKey - The API key for Qdrant.\n * @param https - Whether to use HTTPS.\n */\n constructor({ id, ...qdrantParams }: QdrantClientParams & { id: string }) {\n super({ id });\n this.client = new QdrantClient(qdrantParams);\n }\n\n /**\n * Validates that a named vector exists in the collection.\n * @param indexName - The name of the collection to check.\n * @param vectorName - The name of the vector space to validate.\n * @throws Error if the vector name doesn't exist in the collection.\n */\n private async validateVectorName(indexName: string, vectorName: string): Promise<void> {\n const { config } = await this.client.getCollection(indexName);\n const vectorsConfig = config.params.vectors;\n const isNamedVectors = vectorsConfig && typeof vectorsConfig === 'object' && !('size' in vectorsConfig);\n\n if (!isNamedVectors || !(vectorName in vectorsConfig)) {\n throw new Error(`Vector name \"${vectorName}\" does not exist in collection \"${indexName}\"`);\n }\n }\n\n /**\n * Upserts vectors into the index.\n * @param indexName - The name of the index to upsert into.\n * @param vectors - Array of embedding vectors.\n * @param metadata - Optional metadata for each vector.\n * @param ids - Optional vector IDs (auto-generated if not provided).\n * @param vectorName - Optional name of the vector space when using named vectors.\n */\n async upsert({ indexName, vectors, metadata, ids, vectorName }: QdrantUpsertVectorParams): Promise<string[]> {\n // Validate input parameters\n validateUpsertInput('QDRANT', vectors, metadata, ids);\n const pointIds = ids ? ids.map(id => this.parsePointId(id)) : vectors.map(() => crypto.randomUUID());\n\n // Validate vector name if provided\n if (vectorName) {\n try {\n await this.validateVectorName(indexName, vectorName);\n } catch (validationError) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPSERT', 'INVALID_VECTOR_NAME'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, vectorName },\n },\n validationError,\n );\n }\n }\n\n const records = vectors.map((vector, i) => ({\n id: pointIds[i]!,\n vector: vectorName ? { [vectorName]: vector } : vector,\n payload: metadata?.[i] || {},\n }));\n\n try {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n points: batch,\n wait: true,\n });\n }\n\n return pointIds.map(String);\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length, ...(vectorName && { vectorName }) },\n },\n error,\n );\n }\n }\n\n /**\n * Creates a new index (collection) in Qdrant.\n * Supports both single vector and named vector configurations.\n *\n * @param indexName - The name of the collection to create.\n * @param dimension - Vector dimension (required for single vector mode).\n * @param metric - Distance metric (default: 'cosine').\n * @param namedVectors - Optional named vector configurations for multi-vector collections.\n *\n * @example\n * ```ts\n * // Single vector collection\n * await qdrant.createIndex({ indexName: 'docs', dimension: 768, metric: 'cosine' });\n *\n * // Named vectors collection\n * await qdrant.createIndex({\n * indexName: 'multi-modal',\n * dimension: 768, // Used as fallback, can be omitted with namedVectors\n * namedVectors: {\n * text: { size: 768, distance: 'cosine' },\n * image: { size: 512, distance: 'euclidean' },\n * },\n * });\n * ```\n */\n async createIndex({ indexName, dimension, metric = 'cosine', namedVectors }: QdrantCreateIndexParams): Promise<void> {\n try {\n if (namedVectors) {\n // Validate named vectors configuration\n if (Object.keys(namedVectors).length === 0) {\n throw new Error('namedVectors must contain at least one named vector configuration');\n }\n for (const [name, config] of Object.entries(namedVectors)) {\n if (!Number.isInteger(config.size) || config.size <= 0) {\n throw new Error(`Named vector \"${name}\": size must be a positive integer`);\n }\n if (!DISTANCE_MAPPING[config.distance]) {\n throw new Error(\n `Named vector \"${name}\": invalid distance \"${config.distance}\". Must be one of: cosine, euclidean, dotproduct`,\n );\n }\n }\n } else {\n // Validate single vector configuration\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (!DISTANCE_MAPPING[metric]) {\n throw new Error(`Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`);\n }\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_INDEX', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: {\n indexName,\n dimension,\n metric,\n ...(namedVectors && { namedVectorNames: Object.keys(namedVectors).join(', ') }),\n },\n },\n validationError,\n );\n }\n\n try {\n // Build vectors configuration\n if (namedVectors) {\n const namedVectorsConfig = Object.entries(namedVectors).reduce<\n Record<string, { size: number; distance: Schemas['Distance'] }>\n >((acc, [name, config]) => {\n acc[name] = {\n size: config.size,\n distance: DISTANCE_MAPPING[config.distance]!,\n };\n return acc;\n }, {});\n\n await this.client.createCollection(indexName, {\n vectors: namedVectorsConfig,\n });\n } else {\n await this.client.createCollection(indexName, {\n vectors: {\n size: dimension,\n distance: DISTANCE_MAPPING[metric]!,\n },\n });\n }\n } catch (error: any) {\n const message = error?.message || error?.toString();\n // Qdrant typically returns 409 for existing collection\n if (error?.status === 409 || (typeof message === 'string' && message.toLowerCase().includes('exists'))) {\n if (!namedVectors) {\n // Fetch collection info and check dimension for single vector mode\n await this.validateExistingIndex(indexName, dimension, metric);\n } else {\n // For named vectors, just log and continue (validation is complex)\n this.logger.info(\n `Collection \"${indexName}\" already exists. Skipping validation for named vectors configuration.`,\n );\n }\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: QdrantVectorFilter) {\n const translator = new QdrantFilterTranslator();\n return translator.translate(filter);\n }\n\n /**\n * Queries the index for similar vectors.\n *\n * @param indexName - The name of the index to query.\n * @param queryVector - The query vector to find similar vectors for.\n * @param topK - Number of results to return (default: 10).\n * @param filter - Optional metadata filter.\n * @param includeVector - Whether to include vectors in results (default: false).\n * @param using - Name of the vector space to query when using named vectors.\n */\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n using,\n }: QdrantQueryVectorParams): Promise<QueryResult[]> {\n if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Qdrant queries. Metadata-only queries are not supported by this vector store.',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const translatedFilter = this.transformFilter(filter) ?? {};\n\n try {\n const results = (\n await this.client.query(indexName, {\n query: queryVector,\n limit: topK,\n filter: translatedFilter,\n with_payload: true,\n with_vector: includeVector,\n ...(using ? { using } : {}),\n })\n ).points;\n\n return results.map(match => {\n let vector: number[] = [];\n if (includeVector && match.vector != null) {\n if (Array.isArray(match.vector)) {\n // Single vector mode - already an array of numbers\n vector = match.vector as number[];\n } else if (typeof match.vector === 'object' && match.vector !== null) {\n // Named vectors mode - extract from the correct vector space\n const namedVectors = match.vector as Record<string, unknown>;\n\n // If `using` is specified, try to get that specific vector\n // Otherwise, find the first array in the object\n const sourceArray: unknown[] | undefined =\n using && Array.isArray(namedVectors[using])\n ? (namedVectors[using] as unknown[])\n : (Object.values(namedVectors).find(v => Array.isArray(v)) as unknown[] | undefined);\n\n if (sourceArray) {\n vector = sourceArray.filter((v): v is number => typeof v === 'number');\n }\n }\n }\n\n return {\n id: match.id as string,\n score: match.score || 0,\n metadata: match.payload as Record<string, any>,\n ...(includeVector && { vector }),\n };\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK, ...(using && { using }) },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const response = await this.client.getCollections();\n return response.collections.map(collection => collection.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const { config, points_count } = await this.client.getCollection(indexName);\n\n const distance = config.params.vectors?.distance as Schemas['Distance'];\n return {\n dimension: config.params.vectors?.size as number,\n count: points_count || 0,\n metric: (Object.keys(DISTANCE_MAPPING) as (keyof typeof DISTANCE_MAPPING)[]).find(\n key => DISTANCE_MAPPING[key] === distance,\n ) as IndexStats['metric'],\n };\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection(indexName);\n } catch (error: any) {\n // If the collection doesn't exist, treat it as a no-op (already deleted)\n const errorMessage = error?.message || error?.toString() || '';\n if (\n error?.status === 404 ||\n errorMessage.toLowerCase().includes('not found') ||\n errorMessage.toLowerCase().includes('not exist')\n ) {\n this.logger.info(`Collection ${indexName} does not exist, treating as already deleted`);\n return;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID or multiple vectors matching a filter.\n * @param indexName - The name of the index containing the vector(s).\n * @param id - The ID of the vector to update (mutually exclusive with filter).\n * @param filter - Filter to match multiple vectors to update (mutually exclusive with id).\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<QdrantVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (id && filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!id && !filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'NO_TARGET'),\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\n text: 'No updates provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: {\n indexName,\n ...(id && { id }),\n },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'EMPTY_FILTER'),\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n if (id) {\n // Update single vector by ID\n const pointId = this.parsePointId(id);\n\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n await this.client.setPayload(indexName, { payload: update.metadata, points: [pointId] });\n return;\n }\n\n // Handle vector-only update\n if (update.vector && !update.metadata) {\n await this.client.updateVectors(indexName, {\n points: [\n {\n id: pointId,\n vector: update.vector,\n },\n ],\n });\n return;\n }\n\n // Handle both vector and metadata update\n if (update.vector && update.metadata) {\n const point = {\n id: pointId,\n vector: update.vector,\n payload: update.metadata,\n };\n\n await this.client.upsert(indexName, {\n points: [point],\n });\n }\n } else if (filter) {\n // Update multiple vectors matching filter\n const translatedFilter = this.transformFilter(filter);\n\n // First, scroll through all matching points to get their IDs\n const matchingPoints: Array<{ id: string | number; vector?: number[] }> = [];\n let offset: string | number | undefined = undefined;\n\n do {\n const scrollResult = await this.client.scroll(indexName, {\n filter: translatedFilter,\n limit: 100,\n offset,\n with_payload: false,\n with_vector: !update.vector, // Only fetch vectors if not updating them\n });\n\n matchingPoints.push(\n ...scrollResult.points.map(point => ({\n id: point.id,\n vector: Array.isArray(point.vector) ? (point.vector as number[]) : undefined,\n })),\n );\n\n const nextOffset = scrollResult.next_page_offset;\n offset = typeof nextOffset === 'string' || typeof nextOffset === 'number' ? nextOffset : undefined;\n } while (offset !== undefined);\n\n if (matchingPoints.length === 0) {\n // No vectors to update - this is not an error\n return;\n }\n\n const pointIds = matchingPoints.map(p => p.id);\n\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n await this.client.setPayload(indexName, { payload: update.metadata, points: pointIds });\n return;\n }\n\n // Handle vector-only or both updates\n if (update.vector) {\n // For vector updates with filter, we need to upsert each point\n const points = matchingPoints.map(p => ({\n id: p.id,\n vector: update.vector!,\n payload: update.metadata || {},\n }));\n\n // Batch upsert\n for (let i = 0; i < points.length; i += BATCH_SIZE) {\n const batch = points.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n points: batch,\n wait: true,\n });\n }\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n ...(filter && { filter: JSON.stringify(filter) }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n // Parse the ID - Qdrant supports both string and numeric IDs\n const pointId = this.parsePointId(id);\n\n // Use the Qdrant client to delete the point from the collection\n await this.client.delete(indexName, {\n points: [pointId],\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.\n *\n * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format\n * before sending them to the Qdrant client API.\n *\n * @param id - The ID string to parse\n * @returns The parsed ID as either a number (if string contains only digits) or the original string\n *\n * @example\n * // Numeric ID strings are converted to numbers\n * parsePointId(\"123\") => 123\n * parsePointId(\"42\") => 42\n * parsePointId(\"0\") => 0\n *\n * // String IDs containing any non-digit characters remain as strings\n * parsePointId(\"doc-123\") => \"doc-123\"\n * parsePointId(\"user_42\") => \"user_42\"\n * parsePointId(\"abc123\") => \"abc123\"\n * parsePointId(\"123abc\") => \"123abc\"\n * parsePointId(\"\") => \"\"\n * parsePointId(\"uuid-5678-xyz\") => \"uuid-5678-xyz\"\n *\n * @remarks\n * - This conversion is important because Qdrant treats numeric and string IDs differently\n * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)\n * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions\n * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids\n */\n private parsePointId(id: string): string | number {\n // Try to parse as number if it looks like one\n if (/^\\d+$/.test(id)) {\n return parseInt(id, 10);\n }\n return id;\n }\n\n /**\n * Deletes multiple vectors by IDs or filter.\n * @param indexName - The name of the index containing the vectors.\n * @param ids - Array of vector IDs to delete (mutually exclusive with filter).\n * @param filter - Filter to match vectors to delete (mutually exclusive with ids).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if both ids and filter are provided, or if neither is provided.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<QdrantVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'NO_TARGET'),\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate ids array is not empty\n if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'EMPTY_IDS'),\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'EMPTY_FILTER'),\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n if (ids) {\n // Qdrant rejects the whole batch with a 400 if any ID is not a uint64 or UUID,\n // so surface malformed IDs as a user error instead of letting nothing be deleted.\n const invalidIds = ids.filter(id => !isValidQdrantPointId(id));\n if (invalidIds.length > 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'INVALID_IDS'),\n text: `Invalid Qdrant point IDs (must be unsigned integers or UUIDs): ${invalidIds.join(', ')}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, invalidIds: invalidIds.join(', ') },\n });\n }\n await this.client.delete(indexName, {\n points: ids.map(id => this.parsePointId(id)),\n wait: true,\n });\n } else if (filter) {\n // Delete by filter\n const translatedFilter = this.transformFilter(filter) ?? {};\n await this.client.delete(indexName, {\n filter: translatedFilter as any,\n wait: true,\n });\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Creates a payload index on a Qdrant collection to enable efficient filtering on metadata fields.\n *\n * This is required for Qdrant Cloud and any Qdrant instance with `strict_mode_config = true`,\n * where metadata (payload) fields must be explicitly indexed before they can be used for filtering.\n *\n * @param params - The parameters for creating the payload index.\n * @param params.indexName - The name of the collection (index) to create the payload index on.\n * @param params.fieldName - The name of the payload field to index.\n * @param params.fieldSchema - The schema type for the field (e.g., 'keyword', 'integer', 'text').\n * @param params.wait - Whether to wait for the operation to complete. Defaults to true.\n * @returns A promise that resolves when the index is created (idempotent if index already exists).\n * @throws Will throw a MastraError if arguments are invalid or if the operation fails.\n *\n * @example\n * ```ts\n * // Create a keyword index for filtering by source\n * await qdrant.createPayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'source',\n * fieldSchema: 'keyword',\n * });\n *\n * // Create an integer index for numeric filtering\n * await qdrant.createPayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'price',\n * fieldSchema: 'integer',\n * });\n * ```\n *\n * @see https://qdrant.tech/documentation/concepts/indexing/#payload-index\n */\n async createPayloadIndex({\n indexName,\n fieldName,\n fieldSchema,\n wait = true,\n }: CreatePayloadIndexParams): Promise<void> {\n // Validate inputs\n const validSchemas: PayloadSchemaType[] = [\n 'keyword',\n 'integer',\n 'float',\n 'geo',\n 'text',\n 'bool',\n 'datetime',\n 'uuid',\n ];\n\n if (!indexName || typeof indexName !== 'string' || indexName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'indexName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n if (!fieldName || typeof fieldName !== 'string' || fieldName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'fieldName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n if (!validSchemas.includes(fieldSchema)) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: `fieldSchema must be one of: ${validSchemas.join(', ')}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n try {\n await this.client.createPayloadIndex(indexName, {\n field_name: fieldName,\n field_schema: fieldSchema,\n wait,\n });\n } catch (error: any) {\n const message = error?.message || error?.toString() || '';\n // Qdrant returns 409 or \"exists\" message if index already exists - treat as idempotent success\n if (error?.status === 409 || message.toLowerCase().includes('exists')) {\n this.logger.info(`Payload index for field \"${fieldName}\" already exists on collection \"${indexName}\"`);\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, fieldName, fieldSchema },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a payload index from a Qdrant collection.\n *\n * @param params - The parameters for deleting the payload index.\n * @param params.indexName - The name of the collection (index) to delete the payload index from.\n * @param params.fieldName - The name of the payload field index to delete.\n * @param params.wait - Whether to wait for the operation to complete. Defaults to true.\n * @returns A promise that resolves when the index is deleted (idempotent if index doesn't exist).\n * @throws Will throw a MastraError if the operation fails.\n *\n * @example\n * ```ts\n * await qdrant.deletePayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'source',\n * });\n * ```\n */\n async deletePayloadIndex({ indexName, fieldName, wait = true }: DeletePayloadIndexParams): Promise<void> {\n // Validate inputs\n if (!indexName || typeof indexName !== 'string' || indexName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'indexName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName },\n });\n }\n\n if (!fieldName || typeof fieldName !== 'string' || fieldName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'fieldName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName },\n });\n }\n\n try {\n await this.client.deletePayloadIndex(indexName, fieldName, { wait });\n } catch (error: any) {\n const message = error?.message || error?.toString() || '';\n // If index doesn't exist, treat as idempotent success (already deleted)\n if (\n error?.status === 404 ||\n message.toLowerCase().includes('not found') ||\n message.toLowerCase().includes('not exist')\n ) {\n this.logger.info(`Payload index for field \"${fieldName}\" does not exist on collection \"${indexName}\"`);\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, fieldName },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Qdrant Vector.\n */\nexport const QDRANT_PROMPT = `When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwHA,IAAa,yBAAb,cAA4CA,2BAAAA,qBAAyC;CACnF,kBAAqC,KAAqC;EACxE,OAAO,MAAM,kBAAkB,GAAG,KAAK,QAAQ,YAAY,QAAQ;CACrE;CAEA,wBAA4D;EAC1D,OAAO;GACL,GAAGA,2BAAAA,qBAAqB;GACxB,SAAS;IAAC;IAAQ;IAAO;GAAM;GAC/B,OAAO;IAAC;IAAO;IAAQ;GAAM;GAC7B,OAAO,CAAC,QAAQ;GAChB,SAAS,CAAC,SAAS;GACnB,QAAQ;IAAC;IAAU;IAAQ;IAAW;IAAa;IAAS;IAAU;IAAU;GAAY;EAC9F;CACF;CAEA,WAA8B,KAAyB;EAGrD,OAAO,MAAM,WAAW,GAAG,KAAK,QAAQ;CAC1C;CAEA,UAAU,QAAiD;EACzD,IAAI,KAAK,QAAQ,MAAM,GAAG,OAAO;EACjC,KAAK,eAAe,MAAM;EAC1B,OAAO,KAAK,cAAc,MAAM;CAClC;CAEA,gBAAwB,MAAc,OAAY,UAAmB;EACnE,MAAM,YAAY,GAAG,OAAO,MAAM;EAClC,OAAO,WAAW;GAAE,KAAK;GAAU,GAAG;EAAU,IAAI;CACtD;CAEA,cAAsB,MAA0B,WAAoB,OAAO,UAAwB;EACjG,IAAI,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,QAAQ,OAAO,SAAS,YAAY,UAAU,MACzE,OAAO;EAGT,IAAI,KAAK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A,CAAoB,UAAU,wBAAwB,cAAc;GACxE,MAAM;GACN,QAAQC,mBAAAA,YAAY;GACpB,UAAUC,mBAAAA,cAAc;GACxB,SAAS;IAAE;IAAW;GAAU;EAClC,CAAC;EAGH,IAAI;GACF,MAAM,KAAK,OAAO,mBAAmB,WAAW,WAAW,EAAE,KAAK,CAAC;EACrE,SAAS,OAAY;GACnB,MAAM,UAAU,OAAO,WAAW,OAAO,SAAS,KAAK;GAEvD,IACE,OAAO,WAAW,OAClB,QAAQ,YAAY,CAAC,CAAC,SAAS,WAAW,KAC1C,QAAQ,YAAY,CAAC,CAAC,SAAS,WAAW,GAC1C;IACA,KAAK,OAAO,KAAK,4BAA4B,UAAU,kCAAkC,UAAU,EAAE;IACrG;GACF;GAEA,MAAM,IAAIH,mBAAAA,YACR;IACE,KAAA,GAAIC,qBAAAA,oBAAAA,CAAoB,UAAU,wBAAwB,QAAQ;IAClE,QAAQC,mBAAAA,YAAY;IACpB,UAAUC,mBAAAA,cAAc;IACxB,SAAS;KAAE;KAAW;IAAU;GAClC,GACA,KACF;EACF;CACF;AACF;;;;;;AC/+BA,MAAa,gBAAgB"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createVectorErrorId } from "@mastra/core/storage";
|
|
|
3
3
|
import { MastraVector, validateUpsertInput } from "@mastra/core/vector";
|
|
4
4
|
import { QdrantClient } from "@qdrant/js-client-rest";
|
|
5
5
|
import { BaseFilterTranslator } from "@mastra/core/vector/filter";
|
|
6
|
-
|
|
6
|
+
// src/vector/filter.ts
|
|
7
7
|
/**
|
|
8
8
|
* Translates MongoDB-style filters to Qdrant compatible filters.
|
|
9
9
|
*
|
|
@@ -230,8 +230,7 @@ var QdrantFilterTranslator = class extends BaseFilterTranslator {
|
|
|
230
230
|
return range;
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
|
-
|
|
234
|
-
//#region src/vector/index.ts
|
|
233
|
+
// src/vector/index.ts
|
|
235
234
|
const BATCH_SIZE = 256;
|
|
236
235
|
const DISTANCE_MAPPING = {
|
|
237
236
|
cosine: "Cosine",
|
|
@@ -581,7 +580,6 @@ var QdrantVector = class extends MastraVector {
|
|
|
581
580
|
payload: update.metadata
|
|
582
581
|
};
|
|
583
582
|
await this.client.upsert(indexName, { points: [point] });
|
|
584
|
-
return;
|
|
585
583
|
}
|
|
586
584
|
} else if (filter) {
|
|
587
585
|
const translatedFilter = this.transformFilter(filter);
|
|
@@ -624,7 +622,6 @@ var QdrantVector = class extends MastraVector {
|
|
|
624
622
|
wait: true
|
|
625
623
|
});
|
|
626
624
|
}
|
|
627
|
-
return;
|
|
628
625
|
}
|
|
629
626
|
}
|
|
630
627
|
} catch (error) {
|
|
@@ -932,8 +929,7 @@ var QdrantVector = class extends MastraVector {
|
|
|
932
929
|
}
|
|
933
930
|
}
|
|
934
931
|
};
|
|
935
|
-
|
|
936
|
-
//#region src/vector/prompt.ts
|
|
932
|
+
// src/vector/prompt.ts
|
|
937
933
|
/**
|
|
938
934
|
* Vector store specific prompt that details supported operators and examples.
|
|
939
935
|
* This prompt helps users construct valid filters for Qdrant Vector.
|
|
@@ -1019,7 +1015,6 @@ Example Complex Query:
|
|
|
1019
1015
|
{ "$not": { "status": "discontinued" } }
|
|
1020
1016
|
]
|
|
1021
1017
|
}`;
|
|
1022
|
-
//#endregion
|
|
1023
1018
|
export { QDRANT_PROMPT, QdrantVector };
|
|
1024
1019
|
|
|
1025
1020
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n LogicalOperator,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch'> & {\n /**\n * $count: Filter by array length or value count.\n * Example: { tags: { $count: { gt: 2 } } }\n */\n $count: {\n $gt?: number;\n $gte?: number;\n $lt?: number;\n $lte?: number;\n $eq?: number;\n };\n\n /**\n * $geo: Geospatial filter.\n * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }\n */\n $geo: {\n type: string;\n [key: string]: any;\n };\n\n /**\n * $hasId: Filter by point IDs.\n * Allowed at root level.\n * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }\n */\n $hasId: string | string[];\n\n /**\n * $nested: Nested object filter.\n * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }\n */\n $nested: {\n // Additional properties depend on the nested object structure\n [key: string]: any;\n };\n\n /**\n * $hasVector: Filter by vector existence or field.\n * Allowed at root level.\n * Example: { $hasVector: true } or { $hasVector: 'vector_field' }\n */\n $hasVector: boolean | string;\n\n /**\n * $datetime: RFC 3339 datetime range.\n * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }\n */\n $datetime: {\n key?: string;\n range?: {\n gt?: Date | string;\n gte?: Date | string;\n lt?: Date | string;\n lte?: Date | string;\n eq?: Date | string;\n };\n };\n\n /**\n * $null: Check if a field is null.\n * Example: { metadata: { $null: true } }\n */\n $null: boolean;\n\n /**\n * $empty: Check if an array or object field is empty.\n * Example: { tags: { $empty: true } }\n */\n $empty: boolean;\n};\n\ntype QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype QdrantBlacklistedRootOperators =\n | BlacklistedRootOperators\n | '$count'\n | '$geo'\n | '$nested'\n | '$datetime'\n | '$null'\n | '$empty';\n\nexport type QdrantVectorFilter = VectorFilter<\n keyof QdrantOperatorValueMap,\n QdrantOperatorValueMap,\n QdrantLogicalOperatorValueMap,\n QdrantBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters to Qdrant compatible filters.\n *\n * Key transformations:\n * - $and -> must\n * - $or -> should\n * - $not -> must_not\n * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }\n *\n * Custom operators (Qdrant-specific):\n * - $count -> values_count (array length/value count)\n * - $geo -> geo filters (box, radius, polygon)\n * - $hasId -> has_id filter\n * - $nested -> nested object filters\n * - $hasVector -> vector existence check\n * - $datetime -> RFC 3339 datetime range\n * - $null -> is_null check\n * - $empty -> is_empty check\n */\nexport class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {\n protected override isLogicalOperator(key: string): key is LogicalOperator {\n return super.isLogicalOperator(key) || key === '$hasId' || key === '$hasVector';\n }\n\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or', '$not'],\n array: ['$in', '$nin', '$all'],\n regex: ['$regex'],\n element: ['$exists'],\n custom: ['$count', '$geo', '$nested', '$datetime', '$null', '$empty', '$hasId', '$hasVector'],\n };\n }\n\n protected override isOperator(key: string): key is any {\n // $not can be both a logical operator and a field-level operator\n // When used at field level like { field: { $not: { $gt: 5 } } }, treat it as an operator\n return super.isOperator(key) || key === '$not';\n }\n\n translate(filter?: QdrantVectorFilter): QdrantVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private createCondition(type: string, value: any, fieldKey?: string) {\n const condition = { [type]: value };\n return fieldKey ? { key: fieldKey, ...condition } : condition;\n }\n\n private translateNode(node: QdrantVectorFilter, isNested: boolean = false, fieldKey?: string): any {\n if (!this.isEmpty(node) && !!node && typeof node === 'object' && 'must' in node) {\n return node;\n }\n\n if (this.isPrimitive(node)) {\n if (node === null) {\n return { is_null: { key: fieldKey } };\n }\n return this.createCondition('match', { value: this.normalizeComparisonValue(node) }, fieldKey);\n }\n\n if (this.isRegex(node)) {\n throw new Error('Direct regex pattern format is not supported in Qdrant');\n }\n\n if (Array.isArray(node)) {\n return node.length === 0\n ? { is_empty: { key: fieldKey } }\n : this.createCondition('match', { any: this.normalizeArrayValues(node) }, fieldKey);\n }\n\n const entries = Object.entries(node as Record<string, any>);\n\n // Handle logical operators first (but not $not when we have a fieldKey - that's handled as a field operator)\n const logicalResult = this.handleLogicalOperators(entries, isNested, fieldKey);\n if (logicalResult) {\n return logicalResult;\n }\n\n // Handle field conditions\n const { conditions, range, matchCondition } = this.handleFieldConditions(entries, fieldKey);\n\n if (Object.keys(range).length > 0) {\n conditions.push({ key: fieldKey, range });\n }\n\n if (matchCondition) {\n conditions.push({ key: fieldKey, match: matchCondition });\n }\n\n return this.buildFinalConditions(conditions, isNested);\n }\n\n private buildFinalConditions(conditions: any[], isNested: boolean): any {\n if (conditions.length === 0) {\n return {};\n } else if (conditions.length === 1 && isNested) {\n return conditions[0];\n } else {\n return { must: conditions };\n }\n }\n\n private handleLogicalOperators(entries: [string, any][], isNested: boolean, fieldKey?: string): any | null {\n const firstKey = entries[0]?.[0];\n\n // When we have a fieldKey and see $not, it's a field-level $not operator, not a logical operator\n // Let handleFieldConditions handle it via the _specialNot path\n if (firstKey === '$not' && fieldKey) {\n return null;\n }\n\n if (firstKey && this.isLogicalOperator(firstKey) && !this.isCustomOperator(firstKey)) {\n const [key, value] = entries[0]!;\n const qdrantOp = this.getQdrantLogicalOp(key);\n return {\n [qdrantOp]: Array.isArray(value)\n ? value.map(v => this.translateNode(v, true))\n : [this.translateNode(value, true)],\n };\n }\n\n if (\n entries.length > 1 &&\n !isNested &&\n entries.every(([key]) => !this.isOperator(key) && !this.isCustomOperator(key))\n ) {\n return {\n must: entries.map(([key, value]) => this.translateNode(value, true, key)),\n };\n }\n\n return null;\n }\n\n private handleFieldConditions(\n entries: [string, any][],\n fieldKey?: string,\n ): { conditions: any[]; range: Record<string, any>; matchCondition: Record<string, any> | null } {\n const conditions = [];\n let range: Record<string, any> = {};\n let matchCondition: Record<string, any> | null = null;\n\n for (const [key, value] of entries) {\n if (this.isCustomOperator(key)) {\n const customOp = this.translateCustomOperator(key, value, fieldKey);\n conditions.push(customOp);\n } else if (this.isOperator(key)) {\n const opResult = this.translateOperatorValue(key, value);\n\n // Handle special markers for operators that need custom handling\n if (opResult._specialNull) {\n // $eq: null -> use is_null\n conditions.push({ is_null: { key: fieldKey } });\n } else if (opResult._specialNotNull) {\n // $ne: null -> use must_not with is_null\n conditions.push({ must_not: [{ is_null: { key: fieldKey } }] });\n } else if (opResult._specialNe) {\n // $ne: value -> use must_not with match\n conditions.push({\n must_not: [{ key: fieldKey, match: { value: opResult._specialNe } }],\n });\n } else if (opResult._specialNin) {\n // $nin: [values] -> use must_not with match any\n conditions.push({\n must_not: [{ key: fieldKey, match: { any: opResult._specialNin } }],\n });\n } else if (opResult._specialAll) {\n // $all: [values] -> create multiple match conditions joined with must\n for (const val of opResult._specialAll) {\n conditions.push({ key: fieldKey, match: { value: val } });\n }\n } else if (opResult._specialExists) {\n // $exists: true -> field must not be null or empty\n conditions.push({\n must_not: [{ is_null: { key: fieldKey } }, { is_empty: { key: fieldKey } }],\n });\n } else if (opResult._specialNotExists) {\n // $exists: false -> field must be null or empty\n conditions.push({\n should: [{ is_null: { key: fieldKey } }, { is_empty: { key: fieldKey } }],\n });\n } else if (opResult._specialNot) {\n // $not: { operator: value } -> translate inner condition and wrap in must_not\n const innerResult = this.translateNode(opResult._specialNot, true, fieldKey);\n conditions.push({ must_not: [innerResult] });\n } else if (opResult.range) {\n Object.assign(range, opResult.range);\n } else {\n matchCondition = opResult;\n }\n } else {\n const nestedKey = fieldKey ? `${fieldKey}.${key}` : key;\n const nestedCondition = this.translateNode(value, true, nestedKey);\n\n if (nestedCondition.must) {\n conditions.push(...nestedCondition.must);\n } else if (!this.isEmpty(nestedCondition)) {\n conditions.push(nestedCondition);\n }\n }\n }\n\n return { conditions, range, matchCondition };\n }\n\n private translateCustomOperator(op: string, value: any, fieldKey?: string): any {\n switch (op) {\n case '$count':\n const countConditions = Object.entries(value).reduce(\n (acc, [k, v]) => ({\n ...acc,\n [k.replace('$', '')]: v,\n }),\n {},\n );\n return { key: fieldKey, values_count: countConditions };\n case '$geo':\n const geoOp = this.translateGeoFilter(value.type, value);\n return { key: fieldKey, ...geoOp };\n case '$hasId':\n return { has_id: Array.isArray(value) ? value : [value] };\n case '$nested':\n return {\n nested: {\n key: fieldKey,\n filter: this.translateNode(value),\n },\n };\n case '$hasVector':\n return { has_vector: value };\n case '$datetime':\n return {\n key: fieldKey,\n range: this.normalizeDatetimeRange(value.range),\n };\n case '$null':\n return { is_null: { key: fieldKey } };\n case '$empty':\n return { is_empty: { key: fieldKey } };\n default:\n throw new Error(`Unsupported custom operator: ${op}`);\n }\n }\n\n private getQdrantLogicalOp(op: string): string {\n switch (op) {\n case '$and':\n return 'must';\n case '$or':\n return 'should';\n case '$not':\n return 'must_not';\n default:\n throw new Error(`Unsupported logical operator: ${op}`);\n }\n }\n\n private translateOperatorValue(operator: string, value: any): any {\n const normalizedValue = this.normalizeComparisonValue(value);\n\n switch (operator) {\n case '$eq':\n // Handle null comparison: use is_null instead of match\n if (value === null) {\n return { _specialNull: true };\n }\n return { value: normalizedValue };\n case '$ne':\n // Handle null comparison: for \"not null\", we need is_null wrapped in must_not\n if (value === null) {\n return { _specialNotNull: true };\n }\n // For $ne with non-null values, we need to use must_not with match\n return { _specialNe: normalizedValue };\n case '$gt':\n return { range: { gt: normalizedValue } };\n case '$gte':\n return { range: { gte: normalizedValue } };\n case '$lt':\n return { range: { lt: normalizedValue } };\n case '$lte':\n return { range: { lte: normalizedValue } };\n case '$in':\n return { any: this.normalizeArrayValues(value) };\n case '$nin':\n // Similar to $ne, $nin should use must_not\n return { _specialNin: this.normalizeArrayValues(value) };\n case '$regex':\n return { text: value };\n case '$all':\n // For $all operator, all values must be present in the array\n // Qdrant doesn't have native $all, but we can use must with multiple match conditions\n return { _specialAll: this.normalizeArrayValues(value) };\n case '$exists':\n // $exists: true means field must not be null/empty\n // $exists: false means field must be null or empty\n return value ? { _specialExists: true } : { _specialNotExists: true };\n case '$not':\n // $not wraps another operator\n return { _specialNot: value };\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n }\n\n private translateGeoFilter(type: string, value: any): any {\n switch (type) {\n case 'box':\n return {\n geo_bounding_box: {\n top_left: value.top_left,\n bottom_right: value.bottom_right,\n },\n };\n case 'radius':\n return {\n geo_radius: {\n center: value.center,\n radius: value.radius,\n },\n };\n case 'polygon':\n return {\n geo_polygon: {\n exterior: value.exterior,\n interiors: value.interiors,\n },\n };\n default:\n throw new Error(`Unsupported geo filter type: ${type}`);\n }\n }\n\n private normalizeDatetimeRange(value: any): any {\n const range: Record<string, string> = {};\n for (const [op, val] of Object.entries(value)) {\n if (val instanceof Date) {\n range[op] = val.toISOString();\n } else if (typeof val === 'string') {\n // Assume string is already in proper format\n range[op] = val;\n }\n }\n return range;\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector, validateUpsertInput } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { QdrantClient } from '@qdrant/js-client-rest';\nimport type { QdrantClientParams, Schemas } from '@qdrant/js-client-rest';\n\nimport { QdrantFilterTranslator } from './filter';\nimport type { QdrantVectorFilter } from './filter';\n\nconst BATCH_SIZE = 256;\nconst DISTANCE_MAPPING: Record<string, Schemas['Distance']> = {\n cosine: 'Cosine',\n euclidean: 'Euclid',\n dotproduct: 'Dot',\n};\n\n/**\n * Configuration for a named vector space in Qdrant.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\nexport interface NamedVectorConfig {\n /** The dimension (size) of vectors in this space. */\n size: number;\n /** The distance metric for similarity search. */\n distance: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\n/**\n * Query parameters for Qdrant vector store.\n * Extends the base QueryVectorParams with Qdrant-specific options.\n */\nexport interface QdrantQueryVectorParams extends QueryVectorParams<QdrantVectorFilter> {\n /**\n * Name of the vector field to query against when using named vectors.\n * Use this when your collection has multiple named vector fields.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\n using?: string;\n}\n\n/**\n * Parameters for creating a Qdrant index/collection.\n * Extends the base CreateIndexParams with support for named vectors.\n */\nexport interface QdrantCreateIndexParams extends CreateIndexParams {\n /**\n * Configuration for named vector spaces.\n * When provided, creates a collection with multiple named vector fields.\n * Each key is the vector name, and the value defines its configuration.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n *\n * @example\n * ```ts\n * namedVectors: {\n * text: { size: 768, distance: 'cosine' },\n * image: { size: 512, distance: 'euclidean' },\n * }\n * ```\n */\n namedVectors?: Record<string, NamedVectorConfig>;\n}\n\n/**\n * Parameters for upserting vectors into Qdrant.\n * Extends the base UpsertVectorParams with support for named vectors.\n */\nexport interface QdrantUpsertVectorParams extends UpsertVectorParams {\n /**\n * Name of the vector space to upsert into when using named vectors.\n * Required when the collection was created with namedVectors.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\n vectorName?: string;\n}\n\n/**\n * Supported payload schema types for Qdrant payload indexes.\n * These correspond to Qdrant's native payload indexing types.\n * @see https://qdrant.tech/documentation/concepts/indexing/#payload-index\n */\nexport type PayloadSchemaType = 'keyword' | 'integer' | 'float' | 'geo' | 'text' | 'bool' | 'datetime' | 'uuid';\n\n/**\n * Parameters for creating a payload index on a Qdrant collection.\n */\nexport interface CreatePayloadIndexParams {\n /** The name of the collection (index) to create the payload index on. */\n indexName: string;\n /** The name of the payload field to index. */\n fieldName: string;\n /** The schema type for the payload field. */\n fieldSchema: PayloadSchemaType;\n /** Whether to wait for the operation to complete. Defaults to true. */\n wait?: boolean;\n}\n\n/**\n * Parameters for deleting a payload index from a Qdrant collection.\n */\nexport interface DeletePayloadIndexParams {\n /** The name of the collection (index) to delete the payload index from. */\n indexName: string;\n /** The name of the payload field index to delete. */\n fieldName: string;\n /** Whether to wait for the operation to complete. Defaults to true. */\n wait?: boolean;\n}\n\n// Qdrant accepts simple, hyphenated, braced, and `urn:uuid:` UUID forms.\nconst QDRANT_UUID_REGEX =\n /^(?:urn:uuid:)?(?:[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}|\\{[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}\\})$/i;\nconst QDRANT_MAX_POINT_ID = 18446744073709551615n;\n\nfunction isValidQdrantPointId(id: string): boolean {\n if (/^\\d+$/.test(id)) return BigInt(id) <= QDRANT_MAX_POINT_ID;\n return QDRANT_UUID_REGEX.test(id);\n}\n\nexport class QdrantVector extends MastraVector {\n protected client: QdrantClient;\n\n /**\n * Creates a new QdrantVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param url - The URL of the Qdrant server.\n * @param apiKey - The API key for Qdrant.\n * @param https - Whether to use HTTPS.\n */\n constructor({ id, ...qdrantParams }: QdrantClientParams & { id: string }) {\n super({ id });\n this.client = new QdrantClient(qdrantParams);\n }\n\n /**\n * Validates that a named vector exists in the collection.\n * @param indexName - The name of the collection to check.\n * @param vectorName - The name of the vector space to validate.\n * @throws Error if the vector name doesn't exist in the collection.\n */\n private async validateVectorName(indexName: string, vectorName: string): Promise<void> {\n const { config } = await this.client.getCollection(indexName);\n const vectorsConfig = config.params.vectors;\n const isNamedVectors = vectorsConfig && typeof vectorsConfig === 'object' && !('size' in vectorsConfig);\n\n if (!isNamedVectors || !(vectorName in vectorsConfig)) {\n throw new Error(`Vector name \"${vectorName}\" does not exist in collection \"${indexName}\"`);\n }\n }\n\n /**\n * Upserts vectors into the index.\n * @param indexName - The name of the index to upsert into.\n * @param vectors - Array of embedding vectors.\n * @param metadata - Optional metadata for each vector.\n * @param ids - Optional vector IDs (auto-generated if not provided).\n * @param vectorName - Optional name of the vector space when using named vectors.\n */\n async upsert({ indexName, vectors, metadata, ids, vectorName }: QdrantUpsertVectorParams): Promise<string[]> {\n // Validate input parameters\n validateUpsertInput('QDRANT', vectors, metadata, ids);\n const pointIds = ids ? ids.map(id => this.parsePointId(id)) : vectors.map(() => crypto.randomUUID());\n\n // Validate vector name if provided\n if (vectorName) {\n try {\n await this.validateVectorName(indexName, vectorName);\n } catch (validationError) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPSERT', 'INVALID_VECTOR_NAME'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, vectorName },\n },\n validationError,\n );\n }\n }\n\n const records = vectors.map((vector, i) => ({\n id: pointIds[i]!,\n vector: vectorName ? { [vectorName]: vector } : vector,\n payload: metadata?.[i] || {},\n }));\n\n try {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n points: batch,\n wait: true,\n });\n }\n\n return pointIds.map(String);\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length, ...(vectorName && { vectorName }) },\n },\n error,\n );\n }\n }\n\n /**\n * Creates a new index (collection) in Qdrant.\n * Supports both single vector and named vector configurations.\n *\n * @param indexName - The name of the collection to create.\n * @param dimension - Vector dimension (required for single vector mode).\n * @param metric - Distance metric (default: 'cosine').\n * @param namedVectors - Optional named vector configurations for multi-vector collections.\n *\n * @example\n * ```ts\n * // Single vector collection\n * await qdrant.createIndex({ indexName: 'docs', dimension: 768, metric: 'cosine' });\n *\n * // Named vectors collection\n * await qdrant.createIndex({\n * indexName: 'multi-modal',\n * dimension: 768, // Used as fallback, can be omitted with namedVectors\n * namedVectors: {\n * text: { size: 768, distance: 'cosine' },\n * image: { size: 512, distance: 'euclidean' },\n * },\n * });\n * ```\n */\n async createIndex({ indexName, dimension, metric = 'cosine', namedVectors }: QdrantCreateIndexParams): Promise<void> {\n try {\n if (namedVectors) {\n // Validate named vectors configuration\n if (Object.keys(namedVectors).length === 0) {\n throw new Error('namedVectors must contain at least one named vector configuration');\n }\n for (const [name, config] of Object.entries(namedVectors)) {\n if (!Number.isInteger(config.size) || config.size <= 0) {\n throw new Error(`Named vector \"${name}\": size must be a positive integer`);\n }\n if (!DISTANCE_MAPPING[config.distance]) {\n throw new Error(\n `Named vector \"${name}\": invalid distance \"${config.distance}\". Must be one of: cosine, euclidean, dotproduct`,\n );\n }\n }\n } else {\n // Validate single vector configuration\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (!DISTANCE_MAPPING[metric]) {\n throw new Error(`Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`);\n }\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_INDEX', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: {\n indexName,\n dimension,\n metric,\n ...(namedVectors && { namedVectorNames: Object.keys(namedVectors).join(', ') }),\n },\n },\n validationError,\n );\n }\n\n try {\n // Build vectors configuration\n if (namedVectors) {\n const namedVectorsConfig = Object.entries(namedVectors).reduce(\n (acc, [name, config]) => {\n acc[name] = {\n size: config.size,\n distance: DISTANCE_MAPPING[config.distance]!,\n };\n return acc;\n },\n {} as Record<string, { size: number; distance: Schemas['Distance'] }>,\n );\n\n await this.client.createCollection(indexName, {\n vectors: namedVectorsConfig,\n });\n } else {\n await this.client.createCollection(indexName, {\n vectors: {\n size: dimension,\n distance: DISTANCE_MAPPING[metric]!,\n },\n });\n }\n } catch (error: any) {\n const message = error?.message || error?.toString();\n // Qdrant typically returns 409 for existing collection\n if (error?.status === 409 || (typeof message === 'string' && message.toLowerCase().includes('exists'))) {\n if (!namedVectors) {\n // Fetch collection info and check dimension for single vector mode\n await this.validateExistingIndex(indexName, dimension, metric);\n } else {\n // For named vectors, just log and continue (validation is complex)\n this.logger.info(\n `Collection \"${indexName}\" already exists. Skipping validation for named vectors configuration.`,\n );\n }\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: QdrantVectorFilter) {\n const translator = new QdrantFilterTranslator();\n return translator.translate(filter);\n }\n\n /**\n * Queries the index for similar vectors.\n *\n * @param indexName - The name of the index to query.\n * @param queryVector - The query vector to find similar vectors for.\n * @param topK - Number of results to return (default: 10).\n * @param filter - Optional metadata filter.\n * @param includeVector - Whether to include vectors in results (default: false).\n * @param using - Name of the vector space to query when using named vectors.\n */\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n using,\n }: QdrantQueryVectorParams): Promise<QueryResult[]> {\n if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Qdrant queries. Metadata-only queries are not supported by this vector store.',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const translatedFilter = this.transformFilter(filter) ?? {};\n\n try {\n const results = (\n await this.client.query(indexName, {\n query: queryVector,\n limit: topK,\n filter: translatedFilter,\n with_payload: true,\n with_vector: includeVector,\n ...(using ? { using } : {}),\n })\n ).points;\n\n return results.map(match => {\n let vector: number[] = [];\n if (includeVector && match.vector != null) {\n if (Array.isArray(match.vector)) {\n // Single vector mode - already an array of numbers\n vector = match.vector as number[];\n } else if (typeof match.vector === 'object' && match.vector !== null) {\n // Named vectors mode - extract from the correct vector space\n const namedVectors = match.vector as Record<string, unknown>;\n\n // If `using` is specified, try to get that specific vector\n // Otherwise, find the first array in the object\n const sourceArray: unknown[] | undefined =\n using && Array.isArray(namedVectors[using])\n ? (namedVectors[using] as unknown[])\n : (Object.values(namedVectors).find(v => Array.isArray(v)) as unknown[] | undefined);\n\n if (sourceArray) {\n vector = sourceArray.filter((v): v is number => typeof v === 'number');\n }\n }\n }\n\n return {\n id: match.id as string,\n score: match.score || 0,\n metadata: match.payload as Record<string, any>,\n ...(includeVector && { vector }),\n };\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK, ...(using && { using }) },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const response = await this.client.getCollections();\n return response.collections.map(collection => collection.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const { config, points_count } = await this.client.getCollection(indexName);\n\n const distance = config.params.vectors?.distance as Schemas['Distance'];\n return {\n dimension: config.params.vectors?.size as number,\n count: points_count || 0,\n metric: (Object.keys(DISTANCE_MAPPING) as (keyof typeof DISTANCE_MAPPING)[]).find(\n key => DISTANCE_MAPPING[key] === distance,\n ) as IndexStats['metric'],\n };\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection(indexName);\n } catch (error: any) {\n // If the collection doesn't exist, treat it as a no-op (already deleted)\n const errorMessage = error?.message || error?.toString() || '';\n if (\n error?.status === 404 ||\n errorMessage.toLowerCase().includes('not found') ||\n errorMessage.toLowerCase().includes('not exist')\n ) {\n this.logger.info(`Collection ${indexName} does not exist, treating as already deleted`);\n return;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID or multiple vectors matching a filter.\n * @param indexName - The name of the index containing the vector(s).\n * @param id - The ID of the vector to update (mutually exclusive with filter).\n * @param filter - Filter to match multiple vectors to update (mutually exclusive with id).\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<QdrantVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (id && filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!id && !filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'NO_TARGET'),\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\n text: 'No updates provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: {\n indexName,\n ...(id && { id }),\n },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'EMPTY_FILTER'),\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n if (id) {\n // Update single vector by ID\n const pointId = this.parsePointId(id);\n\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n await this.client.setPayload(indexName, { payload: update.metadata, points: [pointId] });\n return;\n }\n\n // Handle vector-only update\n if (update.vector && !update.metadata) {\n await this.client.updateVectors(indexName, {\n points: [\n {\n id: pointId,\n vector: update.vector,\n },\n ],\n });\n return;\n }\n\n // Handle both vector and metadata update\n if (update.vector && update.metadata) {\n const point = {\n id: pointId,\n vector: update.vector,\n payload: update.metadata,\n };\n\n await this.client.upsert(indexName, {\n points: [point],\n });\n return;\n }\n } else if (filter) {\n // Update multiple vectors matching filter\n const translatedFilter = this.transformFilter(filter);\n\n // First, scroll through all matching points to get their IDs\n const matchingPoints: Array<{ id: string | number; vector?: number[] }> = [];\n let offset: string | number | undefined = undefined;\n\n do {\n const scrollResult = await this.client.scroll(indexName, {\n filter: translatedFilter,\n limit: 100,\n offset,\n with_payload: false,\n with_vector: !update.vector, // Only fetch vectors if not updating them\n });\n\n matchingPoints.push(\n ...scrollResult.points.map(point => ({\n id: point.id,\n vector: Array.isArray(point.vector) ? (point.vector as number[]) : undefined,\n })),\n );\n\n const nextOffset = scrollResult.next_page_offset;\n offset = typeof nextOffset === 'string' || typeof nextOffset === 'number' ? nextOffset : undefined;\n } while (offset !== undefined);\n\n if (matchingPoints.length === 0) {\n // No vectors to update - this is not an error\n return;\n }\n\n const pointIds = matchingPoints.map(p => p.id);\n\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n await this.client.setPayload(indexName, { payload: update.metadata, points: pointIds });\n return;\n }\n\n // Handle vector-only or both updates\n if (update.vector) {\n // For vector updates with filter, we need to upsert each point\n const points = matchingPoints.map(p => ({\n id: p.id,\n vector: update.vector!,\n payload: update.metadata || {},\n }));\n\n // Batch upsert\n for (let i = 0; i < points.length; i += BATCH_SIZE) {\n const batch = points.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n points: batch,\n wait: true,\n });\n }\n return;\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n ...(filter && { filter: JSON.stringify(filter) }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n // Parse the ID - Qdrant supports both string and numeric IDs\n const pointId = this.parsePointId(id);\n\n // Use the Qdrant client to delete the point from the collection\n await this.client.delete(indexName, {\n points: [pointId],\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.\n *\n * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format\n * before sending them to the Qdrant client API.\n *\n * @param id - The ID string to parse\n * @returns The parsed ID as either a number (if string contains only digits) or the original string\n *\n * @example\n * // Numeric ID strings are converted to numbers\n * parsePointId(\"123\") => 123\n * parsePointId(\"42\") => 42\n * parsePointId(\"0\") => 0\n *\n * // String IDs containing any non-digit characters remain as strings\n * parsePointId(\"doc-123\") => \"doc-123\"\n * parsePointId(\"user_42\") => \"user_42\"\n * parsePointId(\"abc123\") => \"abc123\"\n * parsePointId(\"123abc\") => \"123abc\"\n * parsePointId(\"\") => \"\"\n * parsePointId(\"uuid-5678-xyz\") => \"uuid-5678-xyz\"\n *\n * @remarks\n * - This conversion is important because Qdrant treats numeric and string IDs differently\n * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)\n * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions\n * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids\n */\n private parsePointId(id: string): string | number {\n // Try to parse as number if it looks like one\n if (/^\\d+$/.test(id)) {\n return parseInt(id, 10);\n }\n return id;\n }\n\n /**\n * Deletes multiple vectors by IDs or filter.\n * @param indexName - The name of the index containing the vectors.\n * @param ids - Array of vector IDs to delete (mutually exclusive with filter).\n * @param filter - Filter to match vectors to delete (mutually exclusive with ids).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if both ids and filter are provided, or if neither is provided.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<QdrantVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'NO_TARGET'),\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate ids array is not empty\n if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'EMPTY_IDS'),\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'EMPTY_FILTER'),\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n if (ids) {\n // Qdrant rejects the whole batch with a 400 if any ID is not a uint64 or UUID,\n // so surface malformed IDs as a user error instead of letting nothing be deleted.\n const invalidIds = ids.filter(id => !isValidQdrantPointId(id));\n if (invalidIds.length > 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'INVALID_IDS'),\n text: `Invalid Qdrant point IDs (must be unsigned integers or UUIDs): ${invalidIds.join(', ')}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, invalidIds: invalidIds.join(', ') },\n });\n }\n await this.client.delete(indexName, {\n points: ids.map(id => this.parsePointId(id)),\n wait: true,\n });\n } else if (filter) {\n // Delete by filter\n const translatedFilter = this.transformFilter(filter) ?? {};\n await this.client.delete(indexName, {\n filter: translatedFilter as any,\n wait: true,\n });\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Creates a payload index on a Qdrant collection to enable efficient filtering on metadata fields.\n *\n * This is required for Qdrant Cloud and any Qdrant instance with `strict_mode_config = true`,\n * where metadata (payload) fields must be explicitly indexed before they can be used for filtering.\n *\n * @param params - The parameters for creating the payload index.\n * @param params.indexName - The name of the collection (index) to create the payload index on.\n * @param params.fieldName - The name of the payload field to index.\n * @param params.fieldSchema - The schema type for the field (e.g., 'keyword', 'integer', 'text').\n * @param params.wait - Whether to wait for the operation to complete. Defaults to true.\n * @returns A promise that resolves when the index is created (idempotent if index already exists).\n * @throws Will throw a MastraError if arguments are invalid or if the operation fails.\n *\n * @example\n * ```ts\n * // Create a keyword index for filtering by source\n * await qdrant.createPayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'source',\n * fieldSchema: 'keyword',\n * });\n *\n * // Create an integer index for numeric filtering\n * await qdrant.createPayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'price',\n * fieldSchema: 'integer',\n * });\n * ```\n *\n * @see https://qdrant.tech/documentation/concepts/indexing/#payload-index\n */\n async createPayloadIndex({\n indexName,\n fieldName,\n fieldSchema,\n wait = true,\n }: CreatePayloadIndexParams): Promise<void> {\n // Validate inputs\n const validSchemas: PayloadSchemaType[] = [\n 'keyword',\n 'integer',\n 'float',\n 'geo',\n 'text',\n 'bool',\n 'datetime',\n 'uuid',\n ];\n\n if (!indexName || typeof indexName !== 'string' || indexName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'indexName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n if (!fieldName || typeof fieldName !== 'string' || fieldName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'fieldName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n if (!validSchemas.includes(fieldSchema)) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: `fieldSchema must be one of: ${validSchemas.join(', ')}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n try {\n await this.client.createPayloadIndex(indexName, {\n field_name: fieldName,\n field_schema: fieldSchema,\n wait,\n });\n } catch (error: any) {\n const message = error?.message || error?.toString() || '';\n // Qdrant returns 409 or \"exists\" message if index already exists - treat as idempotent success\n if (error?.status === 409 || message.toLowerCase().includes('exists')) {\n this.logger.info(`Payload index for field \"${fieldName}\" already exists on collection \"${indexName}\"`);\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, fieldName, fieldSchema },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a payload index from a Qdrant collection.\n *\n * @param params - The parameters for deleting the payload index.\n * @param params.indexName - The name of the collection (index) to delete the payload index from.\n * @param params.fieldName - The name of the payload field index to delete.\n * @param params.wait - Whether to wait for the operation to complete. Defaults to true.\n * @returns A promise that resolves when the index is deleted (idempotent if index doesn't exist).\n * @throws Will throw a MastraError if the operation fails.\n *\n * @example\n * ```ts\n * await qdrant.deletePayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'source',\n * });\n * ```\n */\n async deletePayloadIndex({ indexName, fieldName, wait = true }: DeletePayloadIndexParams): Promise<void> {\n // Validate inputs\n if (!indexName || typeof indexName !== 'string' || indexName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'indexName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName },\n });\n }\n\n if (!fieldName || typeof fieldName !== 'string' || fieldName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'fieldName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName },\n });\n }\n\n try {\n await this.client.deletePayloadIndex(indexName, fieldName, { wait });\n } catch (error: any) {\n const message = error?.message || error?.toString() || '';\n // If index doesn't exist, treat as idempotent success (already deleted)\n if (\n error?.status === 404 ||\n message.toLowerCase().includes('not found') ||\n message.toLowerCase().includes('not exist')\n ) {\n this.logger.info(`Payload index for field \"${fieldName}\" does not exist on collection \"${indexName}\"`);\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, fieldName },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Qdrant Vector.\n */\nexport const QDRANT_PROMPT = `When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwHA,IAAa,yBAAb,cAA4C,qBAAyC;CACnF,kBAAqC,KAAqC;EAC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;AACF;;;;;;;ACl/BA,MAAa,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n LogicalOperator,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch'> & {\n /**\n * $count: Filter by array length or value count.\n * Example: { tags: { $count: { gt: 2 } } }\n */\n $count: {\n $gt?: number;\n $gte?: number;\n $lt?: number;\n $lte?: number;\n $eq?: number;\n };\n\n /**\n * $geo: Geospatial filter.\n * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }\n */\n $geo: {\n type: string;\n [key: string]: any;\n };\n\n /**\n * $hasId: Filter by point IDs.\n * Allowed at root level.\n * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }\n */\n $hasId: string | string[];\n\n /**\n * $nested: Nested object filter.\n * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }\n */\n $nested: {\n // Additional properties depend on the nested object structure\n [key: string]: any;\n };\n\n /**\n * $hasVector: Filter by vector existence or field.\n * Allowed at root level.\n * Example: { $hasVector: true } or { $hasVector: 'vector_field' }\n */\n $hasVector: boolean | string;\n\n /**\n * $datetime: RFC 3339 datetime range.\n * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }\n */\n $datetime: {\n key?: string;\n range?: {\n gt?: Date | string;\n gte?: Date | string;\n lt?: Date | string;\n lte?: Date | string;\n eq?: Date | string;\n };\n };\n\n /**\n * $null: Check if a field is null.\n * Example: { metadata: { $null: true } }\n */\n $null: boolean;\n\n /**\n * $empty: Check if an array or object field is empty.\n * Example: { tags: { $empty: true } }\n */\n $empty: boolean;\n};\n\ntype QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype QdrantBlacklistedRootOperators =\n | BlacklistedRootOperators\n | '$count'\n | '$geo'\n | '$nested'\n | '$datetime'\n | '$null'\n | '$empty';\n\nexport type QdrantVectorFilter = VectorFilter<\n keyof QdrantOperatorValueMap,\n QdrantOperatorValueMap,\n QdrantLogicalOperatorValueMap,\n QdrantBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters to Qdrant compatible filters.\n *\n * Key transformations:\n * - $and -> must\n * - $or -> should\n * - $not -> must_not\n * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }\n *\n * Custom operators (Qdrant-specific):\n * - $count -> values_count (array length/value count)\n * - $geo -> geo filters (box, radius, polygon)\n * - $hasId -> has_id filter\n * - $nested -> nested object filters\n * - $hasVector -> vector existence check\n * - $datetime -> RFC 3339 datetime range\n * - $null -> is_null check\n * - $empty -> is_empty check\n */\nexport class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {\n protected override isLogicalOperator(key: string): key is LogicalOperator {\n return super.isLogicalOperator(key) || key === '$hasId' || key === '$hasVector';\n }\n\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or', '$not'],\n array: ['$in', '$nin', '$all'],\n regex: ['$regex'],\n element: ['$exists'],\n custom: ['$count', '$geo', '$nested', '$datetime', '$null', '$empty', '$hasId', '$hasVector'],\n };\n }\n\n protected override isOperator(key: string): key is any {\n // $not can be both a logical operator and a field-level operator\n // When used at field level like { field: { $not: { $gt: 5 } } }, treat it as an operator\n return super.isOperator(key) || key === '$not';\n }\n\n translate(filter?: QdrantVectorFilter): QdrantVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private createCondition(type: string, value: any, fieldKey?: string) {\n const condition = { [type]: value };\n return fieldKey ? { key: fieldKey, ...condition } : condition;\n }\n\n private translateNode(node: QdrantVectorFilter, isNested: boolean = false, fieldKey?: string): any {\n if (!this.isEmpty(node) && !!node && typeof node === 'object' && 'must' in node) {\n return node;\n }\n\n if (this.isPrimitive(node)) {\n if (node === null) {\n return { is_null: { key: fieldKey } };\n }\n return this.createCondition('match', { value: this.normalizeComparisonValue(node) }, fieldKey);\n }\n\n if (this.isRegex(node)) {\n throw new Error('Direct regex pattern format is not supported in Qdrant');\n }\n\n if (Array.isArray(node)) {\n return node.length === 0\n ? { is_empty: { key: fieldKey } }\n : this.createCondition('match', { any: this.normalizeArrayValues(node) }, fieldKey);\n }\n\n const entries = Object.entries(node as Record<string, any>);\n\n // Handle logical operators first (but not $not when we have a fieldKey - that's handled as a field operator)\n const logicalResult = this.handleLogicalOperators(entries, isNested, fieldKey);\n if (logicalResult) {\n return logicalResult;\n }\n\n // Handle field conditions\n const { conditions, range, matchCondition } = this.handleFieldConditions(entries, fieldKey);\n\n if (Object.keys(range).length > 0) {\n conditions.push({ key: fieldKey, range });\n }\n\n if (matchCondition) {\n conditions.push({ key: fieldKey, match: matchCondition });\n }\n\n return this.buildFinalConditions(conditions, isNested);\n }\n\n private buildFinalConditions(conditions: any[], isNested: boolean): any {\n if (conditions.length === 0) {\n return {};\n } else if (conditions.length === 1 && isNested) {\n return conditions[0];\n } else {\n return { must: conditions };\n }\n }\n\n private handleLogicalOperators(entries: [string, any][], isNested: boolean, fieldKey?: string): any | null {\n const firstKey = entries[0]?.[0];\n\n // When we have a fieldKey and see $not, it's a field-level $not operator, not a logical operator\n // Let handleFieldConditions handle it via the _specialNot path\n if (firstKey === '$not' && fieldKey) {\n return null;\n }\n\n if (firstKey && this.isLogicalOperator(firstKey) && !this.isCustomOperator(firstKey)) {\n const [key, value] = entries[0]!;\n const qdrantOp = this.getQdrantLogicalOp(key);\n return {\n [qdrantOp]: Array.isArray(value)\n ? value.map(v => this.translateNode(v, true))\n : [this.translateNode(value, true)],\n };\n }\n\n if (\n entries.length > 1 &&\n !isNested &&\n entries.every(([key]) => !this.isOperator(key) && !this.isCustomOperator(key))\n ) {\n return {\n must: entries.map(([key, value]) => this.translateNode(value, true, key)),\n };\n }\n\n return null;\n }\n\n private handleFieldConditions(\n entries: [string, any][],\n fieldKey?: string,\n ): { conditions: any[]; range: Record<string, any>; matchCondition: Record<string, any> | null } {\n const conditions = [];\n let range: Record<string, any> = {};\n let matchCondition: Record<string, any> | null = null;\n\n for (const [key, value] of entries) {\n if (this.isCustomOperator(key)) {\n const customOp = this.translateCustomOperator(key, value, fieldKey);\n conditions.push(customOp);\n } else if (this.isOperator(key)) {\n const opResult = this.translateOperatorValue(key, value);\n\n // Handle special markers for operators that need custom handling\n if (opResult._specialNull) {\n // $eq: null -> use is_null\n conditions.push({ is_null: { key: fieldKey } });\n } else if (opResult._specialNotNull) {\n // $ne: null -> use must_not with is_null\n conditions.push({ must_not: [{ is_null: { key: fieldKey } }] });\n } else if (opResult._specialNe) {\n // $ne: value -> use must_not with match\n conditions.push({\n must_not: [{ key: fieldKey, match: { value: opResult._specialNe } }],\n });\n } else if (opResult._specialNin) {\n // $nin: [values] -> use must_not with match any\n conditions.push({\n must_not: [{ key: fieldKey, match: { any: opResult._specialNin } }],\n });\n } else if (opResult._specialAll) {\n // $all: [values] -> create multiple match conditions joined with must\n for (const val of opResult._specialAll) {\n conditions.push({ key: fieldKey, match: { value: val } });\n }\n } else if (opResult._specialExists) {\n // $exists: true -> field must not be null or empty\n conditions.push({\n must_not: [{ is_null: { key: fieldKey } }, { is_empty: { key: fieldKey } }],\n });\n } else if (opResult._specialNotExists) {\n // $exists: false -> field must be null or empty\n conditions.push({\n should: [{ is_null: { key: fieldKey } }, { is_empty: { key: fieldKey } }],\n });\n } else if (opResult._specialNot) {\n // $not: { operator: value } -> translate inner condition and wrap in must_not\n const innerResult = this.translateNode(opResult._specialNot, true, fieldKey);\n conditions.push({ must_not: [innerResult] });\n } else if (opResult.range) {\n Object.assign(range, opResult.range);\n } else {\n matchCondition = opResult;\n }\n } else {\n const nestedKey = fieldKey ? `${fieldKey}.${key}` : key;\n const nestedCondition = this.translateNode(value, true, nestedKey);\n\n if (nestedCondition.must) {\n conditions.push(...nestedCondition.must);\n } else if (!this.isEmpty(nestedCondition)) {\n conditions.push(nestedCondition);\n }\n }\n }\n\n return { conditions, range, matchCondition };\n }\n\n private translateCustomOperator(op: string, value: any, fieldKey?: string): any {\n switch (op) {\n case '$count':\n const countConditions = Object.entries(value).reduce(\n (acc, [k, v]) => ({\n ...acc,\n [k.replace('$', '')]: v,\n }),\n {},\n );\n return { key: fieldKey, values_count: countConditions };\n case '$geo':\n const geoOp = this.translateGeoFilter(value.type, value);\n return { key: fieldKey, ...geoOp };\n case '$hasId':\n return { has_id: Array.isArray(value) ? value : [value] };\n case '$nested':\n return {\n nested: {\n key: fieldKey,\n filter: this.translateNode(value),\n },\n };\n case '$hasVector':\n return { has_vector: value };\n case '$datetime':\n return {\n key: fieldKey,\n range: this.normalizeDatetimeRange(value.range),\n };\n case '$null':\n return { is_null: { key: fieldKey } };\n case '$empty':\n return { is_empty: { key: fieldKey } };\n default:\n throw new Error(`Unsupported custom operator: ${op}`);\n }\n }\n\n private getQdrantLogicalOp(op: string): string {\n switch (op) {\n case '$and':\n return 'must';\n case '$or':\n return 'should';\n case '$not':\n return 'must_not';\n default:\n throw new Error(`Unsupported logical operator: ${op}`);\n }\n }\n\n private translateOperatorValue(operator: string, value: any): any {\n const normalizedValue = this.normalizeComparisonValue(value);\n\n switch (operator) {\n case '$eq':\n // Handle null comparison: use is_null instead of match\n if (value === null) {\n return { _specialNull: true };\n }\n return { value: normalizedValue };\n case '$ne':\n // Handle null comparison: for \"not null\", we need is_null wrapped in must_not\n if (value === null) {\n return { _specialNotNull: true };\n }\n // For $ne with non-null values, we need to use must_not with match\n return { _specialNe: normalizedValue };\n case '$gt':\n return { range: { gt: normalizedValue } };\n case '$gte':\n return { range: { gte: normalizedValue } };\n case '$lt':\n return { range: { lt: normalizedValue } };\n case '$lte':\n return { range: { lte: normalizedValue } };\n case '$in':\n return { any: this.normalizeArrayValues(value) };\n case '$nin':\n // Similar to $ne, $nin should use must_not\n return { _specialNin: this.normalizeArrayValues(value) };\n case '$regex':\n return { text: value };\n case '$all':\n // For $all operator, all values must be present in the array\n // Qdrant doesn't have native $all, but we can use must with multiple match conditions\n return { _specialAll: this.normalizeArrayValues(value) };\n case '$exists':\n // $exists: true means field must not be null/empty\n // $exists: false means field must be null or empty\n return value ? { _specialExists: true } : { _specialNotExists: true };\n case '$not':\n // $not wraps another operator\n return { _specialNot: value };\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n }\n\n private translateGeoFilter(type: string, value: any): any {\n switch (type) {\n case 'box':\n return {\n geo_bounding_box: {\n top_left: value.top_left,\n bottom_right: value.bottom_right,\n },\n };\n case 'radius':\n return {\n geo_radius: {\n center: value.center,\n radius: value.radius,\n },\n };\n case 'polygon':\n return {\n geo_polygon: {\n exterior: value.exterior,\n interiors: value.interiors,\n },\n };\n default:\n throw new Error(`Unsupported geo filter type: ${type}`);\n }\n }\n\n private normalizeDatetimeRange(value: any): any {\n const range: Record<string, string> = {};\n for (const [op, val] of Object.entries(value)) {\n if (val instanceof Date) {\n range[op] = val.toISOString();\n } else if (typeof val === 'string') {\n // Assume string is already in proper format\n range[op] = val;\n }\n }\n return range;\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { createVectorErrorId } from '@mastra/core/storage';\nimport { MastraVector, validateUpsertInput } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n DeleteVectorsParams,\n} from '@mastra/core/vector';\nimport { QdrantClient } from '@qdrant/js-client-rest';\nimport type { QdrantClientParams, Schemas } from '@qdrant/js-client-rest';\n\nimport { QdrantFilterTranslator } from './filter';\nimport type { QdrantVectorFilter } from './filter';\n\nconst BATCH_SIZE = 256;\nconst DISTANCE_MAPPING: Record<string, Schemas['Distance']> = {\n cosine: 'Cosine',\n euclidean: 'Euclid',\n dotproduct: 'Dot',\n};\n\n/**\n * Configuration for a named vector space in Qdrant.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\nexport interface NamedVectorConfig {\n /** The dimension (size) of vectors in this space. */\n size: number;\n /** The distance metric for similarity search. */\n distance: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\n/**\n * Query parameters for Qdrant vector store.\n * Extends the base QueryVectorParams with Qdrant-specific options.\n */\nexport interface QdrantQueryVectorParams extends QueryVectorParams<QdrantVectorFilter> {\n /**\n * Name of the vector field to query against when using named vectors.\n * Use this when your collection has multiple named vector fields.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\n using?: string;\n}\n\n/**\n * Parameters for creating a Qdrant index/collection.\n * Extends the base CreateIndexParams with support for named vectors.\n */\nexport interface QdrantCreateIndexParams extends CreateIndexParams {\n /**\n * Configuration for named vector spaces.\n * When provided, creates a collection with multiple named vector fields.\n * Each key is the vector name, and the value defines its configuration.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n *\n * @example\n * ```ts\n * namedVectors: {\n * text: { size: 768, distance: 'cosine' },\n * image: { size: 512, distance: 'euclidean' },\n * }\n * ```\n */\n namedVectors?: Record<string, NamedVectorConfig>;\n}\n\n/**\n * Parameters for upserting vectors into Qdrant.\n * Extends the base UpsertVectorParams with support for named vectors.\n */\nexport interface QdrantUpsertVectorParams extends UpsertVectorParams {\n /**\n * Name of the vector space to upsert into when using named vectors.\n * Required when the collection was created with namedVectors.\n * @see https://qdrant.tech/documentation/concepts/vectors/#named-vectors\n */\n vectorName?: string;\n}\n\n/**\n * Supported payload schema types for Qdrant payload indexes.\n * These correspond to Qdrant's native payload indexing types.\n * @see https://qdrant.tech/documentation/concepts/indexing/#payload-index\n */\nexport type PayloadSchemaType = 'keyword' | 'integer' | 'float' | 'geo' | 'text' | 'bool' | 'datetime' | 'uuid';\n\n/**\n * Parameters for creating a payload index on a Qdrant collection.\n */\nexport interface CreatePayloadIndexParams {\n /** The name of the collection (index) to create the payload index on. */\n indexName: string;\n /** The name of the payload field to index. */\n fieldName: string;\n /** The schema type for the payload field. */\n fieldSchema: PayloadSchemaType;\n /** Whether to wait for the operation to complete. Defaults to true. */\n wait?: boolean;\n}\n\n/**\n * Parameters for deleting a payload index from a Qdrant collection.\n */\nexport interface DeletePayloadIndexParams {\n /** The name of the collection (index) to delete the payload index from. */\n indexName: string;\n /** The name of the payload field index to delete. */\n fieldName: string;\n /** Whether to wait for the operation to complete. Defaults to true. */\n wait?: boolean;\n}\n\n// Qdrant accepts simple, hyphenated, braced, and `urn:uuid:` UUID forms.\nconst QDRANT_UUID_REGEX =\n /^(?:urn:uuid:)?(?:[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}|\\{[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}\\})$/i;\nconst QDRANT_MAX_POINT_ID = 18446744073709551615n;\n\nfunction isValidQdrantPointId(id: string): boolean {\n if (/^\\d+$/.test(id)) return BigInt(id) <= QDRANT_MAX_POINT_ID;\n return QDRANT_UUID_REGEX.test(id);\n}\n\nexport class QdrantVector extends MastraVector {\n protected client: QdrantClient;\n\n /**\n * Creates a new QdrantVector client.\n * @param id - The unique identifier for this vector store instance.\n * @param url - The URL of the Qdrant server.\n * @param apiKey - The API key for Qdrant.\n * @param https - Whether to use HTTPS.\n */\n constructor({ id, ...qdrantParams }: QdrantClientParams & { id: string }) {\n super({ id });\n this.client = new QdrantClient(qdrantParams);\n }\n\n /**\n * Validates that a named vector exists in the collection.\n * @param indexName - The name of the collection to check.\n * @param vectorName - The name of the vector space to validate.\n * @throws Error if the vector name doesn't exist in the collection.\n */\n private async validateVectorName(indexName: string, vectorName: string): Promise<void> {\n const { config } = await this.client.getCollection(indexName);\n const vectorsConfig = config.params.vectors;\n const isNamedVectors = vectorsConfig && typeof vectorsConfig === 'object' && !('size' in vectorsConfig);\n\n if (!isNamedVectors || !(vectorName in vectorsConfig)) {\n throw new Error(`Vector name \"${vectorName}\" does not exist in collection \"${indexName}\"`);\n }\n }\n\n /**\n * Upserts vectors into the index.\n * @param indexName - The name of the index to upsert into.\n * @param vectors - Array of embedding vectors.\n * @param metadata - Optional metadata for each vector.\n * @param ids - Optional vector IDs (auto-generated if not provided).\n * @param vectorName - Optional name of the vector space when using named vectors.\n */\n async upsert({ indexName, vectors, metadata, ids, vectorName }: QdrantUpsertVectorParams): Promise<string[]> {\n // Validate input parameters\n validateUpsertInput('QDRANT', vectors, metadata, ids);\n const pointIds = ids ? ids.map(id => this.parsePointId(id)) : vectors.map(() => crypto.randomUUID());\n\n // Validate vector name if provided\n if (vectorName) {\n try {\n await this.validateVectorName(indexName, vectorName);\n } catch (validationError) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPSERT', 'INVALID_VECTOR_NAME'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, vectorName },\n },\n validationError,\n );\n }\n }\n\n const records = vectors.map((vector, i) => ({\n id: pointIds[i]!,\n vector: vectorName ? { [vectorName]: vector } : vector,\n payload: metadata?.[i] || {},\n }));\n\n try {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n points: batch,\n wait: true,\n });\n }\n\n return pointIds.map(String);\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPSERT', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length, ...(vectorName && { vectorName }) },\n },\n error,\n );\n }\n }\n\n /**\n * Creates a new index (collection) in Qdrant.\n * Supports both single vector and named vector configurations.\n *\n * @param indexName - The name of the collection to create.\n * @param dimension - Vector dimension (required for single vector mode).\n * @param metric - Distance metric (default: 'cosine').\n * @param namedVectors - Optional named vector configurations for multi-vector collections.\n *\n * @example\n * ```ts\n * // Single vector collection\n * await qdrant.createIndex({ indexName: 'docs', dimension: 768, metric: 'cosine' });\n *\n * // Named vectors collection\n * await qdrant.createIndex({\n * indexName: 'multi-modal',\n * dimension: 768, // Used as fallback, can be omitted with namedVectors\n * namedVectors: {\n * text: { size: 768, distance: 'cosine' },\n * image: { size: 512, distance: 'euclidean' },\n * },\n * });\n * ```\n */\n async createIndex({ indexName, dimension, metric = 'cosine', namedVectors }: QdrantCreateIndexParams): Promise<void> {\n try {\n if (namedVectors) {\n // Validate named vectors configuration\n if (Object.keys(namedVectors).length === 0) {\n throw new Error('namedVectors must contain at least one named vector configuration');\n }\n for (const [name, config] of Object.entries(namedVectors)) {\n if (!Number.isInteger(config.size) || config.size <= 0) {\n throw new Error(`Named vector \"${name}\": size must be a positive integer`);\n }\n if (!DISTANCE_MAPPING[config.distance]) {\n throw new Error(\n `Named vector \"${name}\": invalid distance \"${config.distance}\". Must be one of: cosine, euclidean, dotproduct`,\n );\n }\n }\n } else {\n // Validate single vector configuration\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (!DISTANCE_MAPPING[metric]) {\n throw new Error(`Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`);\n }\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_INDEX', 'INVALID_ARGS'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: {\n indexName,\n dimension,\n metric,\n ...(namedVectors && { namedVectorNames: Object.keys(namedVectors).join(', ') }),\n },\n },\n validationError,\n );\n }\n\n try {\n // Build vectors configuration\n if (namedVectors) {\n const namedVectorsConfig = Object.entries(namedVectors).reduce<\n Record<string, { size: number; distance: Schemas['Distance'] }>\n >((acc, [name, config]) => {\n acc[name] = {\n size: config.size,\n distance: DISTANCE_MAPPING[config.distance]!,\n };\n return acc;\n }, {});\n\n await this.client.createCollection(indexName, {\n vectors: namedVectorsConfig,\n });\n } else {\n await this.client.createCollection(indexName, {\n vectors: {\n size: dimension,\n distance: DISTANCE_MAPPING[metric]!,\n },\n });\n }\n } catch (error: any) {\n const message = error?.message || error?.toString();\n // Qdrant typically returns 409 for existing collection\n if (error?.status === 409 || (typeof message === 'string' && message.toLowerCase().includes('exists'))) {\n if (!namedVectors) {\n // Fetch collection info and check dimension for single vector mode\n await this.validateExistingIndex(indexName, dimension, metric);\n } else {\n // For named vectors, just log and continue (validation is complex)\n this.logger.info(\n `Collection \"${indexName}\" already exists. Skipping validation for named vectors configuration.`,\n );\n }\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: QdrantVectorFilter) {\n const translator = new QdrantFilterTranslator();\n return translator.translate(filter);\n }\n\n /**\n * Queries the index for similar vectors.\n *\n * @param indexName - The name of the index to query.\n * @param queryVector - The query vector to find similar vectors for.\n * @param topK - Number of results to return (default: 10).\n * @param filter - Optional metadata filter.\n * @param includeVector - Whether to include vectors in results (default: false).\n * @param using - Name of the vector space to query when using named vectors.\n */\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n using,\n }: QdrantQueryVectorParams): Promise<QueryResult[]> {\n if (!queryVector) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'QUERY', 'MISSING_VECTOR'),\n text: 'queryVector is required for Qdrant queries. Metadata-only queries are not supported by this vector store.',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n const translatedFilter = this.transformFilter(filter) ?? {};\n\n try {\n const results = (\n await this.client.query(indexName, {\n query: queryVector,\n limit: topK,\n filter: translatedFilter,\n with_payload: true,\n with_vector: includeVector,\n ...(using ? { using } : {}),\n })\n ).points;\n\n return results.map(match => {\n let vector: number[] = [];\n if (includeVector && match.vector != null) {\n if (Array.isArray(match.vector)) {\n // Single vector mode - already an array of numbers\n vector = match.vector as number[];\n } else if (typeof match.vector === 'object' && match.vector !== null) {\n // Named vectors mode - extract from the correct vector space\n const namedVectors = match.vector as Record<string, unknown>;\n\n // If `using` is specified, try to get that specific vector\n // Otherwise, find the first array in the object\n const sourceArray: unknown[] | undefined =\n using && Array.isArray(namedVectors[using])\n ? (namedVectors[using] as unknown[])\n : (Object.values(namedVectors).find(v => Array.isArray(v)) as unknown[] | undefined);\n\n if (sourceArray) {\n vector = sourceArray.filter((v): v is number => typeof v === 'number');\n }\n }\n }\n\n return {\n id: match.id as string,\n score: match.score || 0,\n metadata: match.payload as Record<string, any>,\n ...(includeVector && { vector }),\n };\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'QUERY', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK, ...(using && { using }) },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const response = await this.client.getCollections();\n return response.collections.map(collection => collection.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'LIST_INDEXES', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const { config, points_count } = await this.client.getCollection(indexName);\n\n const distance = config.params.vectors?.distance as Schemas['Distance'];\n return {\n dimension: config.params.vectors?.size as number,\n count: points_count || 0,\n metric: (Object.keys(DISTANCE_MAPPING) as (keyof typeof DISTANCE_MAPPING)[]).find(\n key => DISTANCE_MAPPING[key] === distance,\n ) as IndexStats['metric'],\n };\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DESCRIBE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection(indexName);\n } catch (error: any) {\n // If the collection doesn't exist, treat it as a no-op (already deleted)\n const errorMessage = error?.message || error?.toString() || '';\n if (\n error?.status === 404 ||\n errorMessage.toLowerCase().includes('not found') ||\n errorMessage.toLowerCase().includes('not exist')\n ) {\n this.logger.info(`Collection ${indexName} does not exist, treating as already deleted`);\n return;\n }\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID or multiple vectors matching a filter.\n * @param indexName - The name of the index containing the vector(s).\n * @param id - The ID of the vector to update (mutually exclusive with filter).\n * @param filter - Filter to match multiple vectors to update (mutually exclusive with id).\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, filter, update }: UpdateVectorParams<QdrantVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (id && filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both id and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!id && !filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'NO_TARGET'),\n text: 'Either id or filter must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'NO_PAYLOAD'),\n text: 'No updates provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: {\n indexName,\n ...(id && { id }),\n },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'EMPTY_FILTER'),\n text: 'Filter cannot be an empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n if (id) {\n // Update single vector by ID\n const pointId = this.parsePointId(id);\n\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n await this.client.setPayload(indexName, { payload: update.metadata, points: [pointId] });\n return;\n }\n\n // Handle vector-only update\n if (update.vector && !update.metadata) {\n await this.client.updateVectors(indexName, {\n points: [\n {\n id: pointId,\n vector: update.vector,\n },\n ],\n });\n return;\n }\n\n // Handle both vector and metadata update\n if (update.vector && update.metadata) {\n const point = {\n id: pointId,\n vector: update.vector,\n payload: update.metadata,\n };\n\n await this.client.upsert(indexName, {\n points: [point],\n });\n }\n } else if (filter) {\n // Update multiple vectors matching filter\n const translatedFilter = this.transformFilter(filter);\n\n // First, scroll through all matching points to get their IDs\n const matchingPoints: Array<{ id: string | number; vector?: number[] }> = [];\n let offset: string | number | undefined = undefined;\n\n do {\n const scrollResult = await this.client.scroll(indexName, {\n filter: translatedFilter,\n limit: 100,\n offset,\n with_payload: false,\n with_vector: !update.vector, // Only fetch vectors if not updating them\n });\n\n matchingPoints.push(\n ...scrollResult.points.map(point => ({\n id: point.id,\n vector: Array.isArray(point.vector) ? (point.vector as number[]) : undefined,\n })),\n );\n\n const nextOffset = scrollResult.next_page_offset;\n offset = typeof nextOffset === 'string' || typeof nextOffset === 'number' ? nextOffset : undefined;\n } while (offset !== undefined);\n\n if (matchingPoints.length === 0) {\n // No vectors to update - this is not an error\n return;\n }\n\n const pointIds = matchingPoints.map(p => p.id);\n\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n await this.client.setPayload(indexName, { payload: update.metadata, points: pointIds });\n return;\n }\n\n // Handle vector-only or both updates\n if (update.vector) {\n // For vector updates with filter, we need to upsert each point\n const points = matchingPoints.map(p => ({\n id: p.id,\n vector: update.vector!,\n payload: update.metadata || {},\n }));\n\n // Batch upsert\n for (let i = 0; i < points.length; i += BATCH_SIZE) {\n const batch = points.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n points: batch,\n wait: true,\n });\n }\n }\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'UPDATE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n ...(filter && { filter: JSON.stringify(filter) }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n // Parse the ID - Qdrant supports both string and numeric IDs\n const pointId = this.parsePointId(id);\n\n // Use the Qdrant client to delete the point from the collection\n await this.client.delete(indexName, {\n points: [pointId],\n });\n } catch (error) {\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_VECTOR', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(id && { id }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.\n *\n * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format\n * before sending them to the Qdrant client API.\n *\n * @param id - The ID string to parse\n * @returns The parsed ID as either a number (if string contains only digits) or the original string\n *\n * @example\n * // Numeric ID strings are converted to numbers\n * parsePointId(\"123\") => 123\n * parsePointId(\"42\") => 42\n * parsePointId(\"0\") => 0\n *\n * // String IDs containing any non-digit characters remain as strings\n * parsePointId(\"doc-123\") => \"doc-123\"\n * parsePointId(\"user_42\") => \"user_42\"\n * parsePointId(\"abc123\") => \"abc123\"\n * parsePointId(\"123abc\") => \"123abc\"\n * parsePointId(\"\") => \"\"\n * parsePointId(\"uuid-5678-xyz\") => \"uuid-5678-xyz\"\n *\n * @remarks\n * - This conversion is important because Qdrant treats numeric and string IDs differently\n * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)\n * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions\n * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids\n */\n private parsePointId(id: string): string | number {\n // Try to parse as number if it looks like one\n if (/^\\d+$/.test(id)) {\n return parseInt(id, 10);\n }\n return id;\n }\n\n /**\n * Deletes multiple vectors by IDs or filter.\n * @param indexName - The name of the index containing the vectors.\n * @param ids - Array of vector IDs to delete (mutually exclusive with filter).\n * @param filter - Filter to match vectors to delete (mutually exclusive with ids).\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if both ids and filter are provided, or if neither is provided.\n */\n async deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<QdrantVectorFilter>): Promise<void> {\n // Validate mutually exclusive parameters\n if (ids && filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'MUTUALLY_EXCLUSIVE'),\n text: 'Cannot specify both ids and filter - they are mutually exclusive',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n if (!ids && !filter) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'NO_TARGET'),\n text: 'Either filter or ids must be provided',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate ids array is not empty\n if (ids && ids.length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'EMPTY_IDS'),\n text: 'Cannot delete with empty ids array',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n // Validate filter is not empty\n if (filter && Object.keys(filter).length === 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'EMPTY_FILTER'),\n text: 'Cannot delete with empty filter object',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName },\n });\n }\n\n try {\n if (ids) {\n // Qdrant rejects the whole batch with a 400 if any ID is not a uint64 or UUID,\n // so surface malformed IDs as a user error instead of letting nothing be deleted.\n const invalidIds = ids.filter(id => !isValidQdrantPointId(id));\n if (invalidIds.length > 0) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'INVALID_IDS'),\n text: `Invalid Qdrant point IDs (must be unsigned integers or UUIDs): ${invalidIds.join(', ')}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, invalidIds: invalidIds.join(', ') },\n });\n }\n await this.client.delete(indexName, {\n points: ids.map(id => this.parsePointId(id)),\n wait: true,\n });\n } else if (filter) {\n // Delete by filter\n const translatedFilter = this.transformFilter(filter) ?? {};\n await this.client.delete(indexName, {\n filter: translatedFilter as any,\n wait: true,\n });\n }\n } catch (error) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_VECTORS', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: {\n indexName,\n ...(filter && { filter: JSON.stringify(filter) }),\n ...(ids && { idsCount: ids.length }),\n },\n },\n error,\n );\n }\n }\n\n /**\n * Creates a payload index on a Qdrant collection to enable efficient filtering on metadata fields.\n *\n * This is required for Qdrant Cloud and any Qdrant instance with `strict_mode_config = true`,\n * where metadata (payload) fields must be explicitly indexed before they can be used for filtering.\n *\n * @param params - The parameters for creating the payload index.\n * @param params.indexName - The name of the collection (index) to create the payload index on.\n * @param params.fieldName - The name of the payload field to index.\n * @param params.fieldSchema - The schema type for the field (e.g., 'keyword', 'integer', 'text').\n * @param params.wait - Whether to wait for the operation to complete. Defaults to true.\n * @returns A promise that resolves when the index is created (idempotent if index already exists).\n * @throws Will throw a MastraError if arguments are invalid or if the operation fails.\n *\n * @example\n * ```ts\n * // Create a keyword index for filtering by source\n * await qdrant.createPayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'source',\n * fieldSchema: 'keyword',\n * });\n *\n * // Create an integer index for numeric filtering\n * await qdrant.createPayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'price',\n * fieldSchema: 'integer',\n * });\n * ```\n *\n * @see https://qdrant.tech/documentation/concepts/indexing/#payload-index\n */\n async createPayloadIndex({\n indexName,\n fieldName,\n fieldSchema,\n wait = true,\n }: CreatePayloadIndexParams): Promise<void> {\n // Validate inputs\n const validSchemas: PayloadSchemaType[] = [\n 'keyword',\n 'integer',\n 'float',\n 'geo',\n 'text',\n 'bool',\n 'datetime',\n 'uuid',\n ];\n\n if (!indexName || typeof indexName !== 'string' || indexName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'indexName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n if (!fieldName || typeof fieldName !== 'string' || fieldName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'fieldName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n if (!validSchemas.includes(fieldSchema)) {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: `fieldSchema must be one of: ${validSchemas.join(', ')}`,\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName, fieldSchema },\n });\n }\n\n try {\n await this.client.createPayloadIndex(indexName, {\n field_name: fieldName,\n field_schema: fieldSchema,\n wait,\n });\n } catch (error: any) {\n const message = error?.message || error?.toString() || '';\n // Qdrant returns 409 or \"exists\" message if index already exists - treat as idempotent success\n if (error?.status === 409 || message.toLowerCase().includes('exists')) {\n this.logger.info(`Payload index for field \"${fieldName}\" already exists on collection \"${indexName}\"`);\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'CREATE_PAYLOAD_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, fieldName, fieldSchema },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a payload index from a Qdrant collection.\n *\n * @param params - The parameters for deleting the payload index.\n * @param params.indexName - The name of the collection (index) to delete the payload index from.\n * @param params.fieldName - The name of the payload field index to delete.\n * @param params.wait - Whether to wait for the operation to complete. Defaults to true.\n * @returns A promise that resolves when the index is deleted (idempotent if index doesn't exist).\n * @throws Will throw a MastraError if the operation fails.\n *\n * @example\n * ```ts\n * await qdrant.deletePayloadIndex({\n * indexName: 'my-collection',\n * fieldName: 'source',\n * });\n * ```\n */\n async deletePayloadIndex({ indexName, fieldName, wait = true }: DeletePayloadIndexParams): Promise<void> {\n // Validate inputs\n if (!indexName || typeof indexName !== 'string' || indexName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'indexName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName },\n });\n }\n\n if (!fieldName || typeof fieldName !== 'string' || fieldName.trim() === '') {\n throw new MastraError({\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'INVALID_ARGS'),\n text: 'fieldName must be a non-empty string',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, fieldName },\n });\n }\n\n try {\n await this.client.deletePayloadIndex(indexName, fieldName, { wait });\n } catch (error: any) {\n const message = error?.message || error?.toString() || '';\n // If index doesn't exist, treat as idempotent success (already deleted)\n if (\n error?.status === 404 ||\n message.toLowerCase().includes('not found') ||\n message.toLowerCase().includes('not exist')\n ) {\n this.logger.info(`Payload index for field \"${fieldName}\" does not exist on collection \"${indexName}\"`);\n return;\n }\n\n throw new MastraError(\n {\n id: createVectorErrorId('QDRANT', 'DELETE_PAYLOAD_INDEX', 'FAILED'),\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, fieldName },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Qdrant Vector.\n */\nexport const QDRANT_PROMPT = `When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwHA,IAAa,yBAAb,cAA4C,qBAAyC;CACnF,kBAAqC,KAAqC;EACxE,OAAO,MAAM,kBAAkB,GAAG,KAAK,QAAQ,YAAY,QAAQ;CACrE;CAEA,wBAA4D;EAC1D,OAAO;GACL,GAAG,qBAAqB;GACxB,SAAS;IAAC;IAAQ;IAAO;GAAM;GAC/B,OAAO;IAAC;IAAO;IAAQ;GAAM;GAC7B,OAAO,CAAC,QAAQ;GAChB,SAAS,CAAC,SAAS;GACnB,QAAQ;IAAC;IAAU;IAAQ;IAAW;IAAa;IAAS;IAAU;IAAU;GAAY;EAC9F;CACF;CAEA,WAA8B,KAAyB;EAGrD,OAAO,MAAM,WAAW,GAAG,KAAK,QAAQ;CAC1C;CAEA,UAAU,QAAiD;EACzD,IAAI,KAAK,QAAQ,MAAM,GAAG,OAAO;EACjC,KAAK,eAAe,MAAM;EAC1B,OAAO,KAAK,cAAc,MAAM;CAClC;CAEA,gBAAwB,MAAc,OAAY,UAAmB;EACnE,MAAM,YAAY,GAAG,OAAO,MAAM;EAClC,OAAO,WAAW;GAAE,KAAK;GAAU,GAAG;EAAU,IAAI;CACtD;CAEA,cAAsB,MAA0B,WAAoB,OAAO,UAAwB;EACjG,IAAI,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,QAAQ,OAAO,SAAS,YAAY,UAAU,MACzE,OAAO;EAGT,IAAI,KAAK,YAAY,IAAI,GAAG;GAC1B,IAAI,SAAS,MACX,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE;GAEtC,OAAO,KAAK,gBAAgB,SAAS,EAAE,OA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AC,CAcrC;IAED;;;;;OAKG;IACG,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAuB3E;IAEK,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBjE;IAED;;;;;;;;;;OAUG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA8J3G;IAED;;;;;;OAMG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBvE;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;;;OAOG;IACG,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsFtG;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,kBAAkB,CAAC,EACvB,SAAS,EACT,SAAS,EACT,WAAW,EACX,IAAW,GACZ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE1C;IAED;;;;;;;;;;;;;;;;;OAiBG;IACG,kBAAkB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,IAAW,EAAE,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8CvG;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/qdrant",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6-alpha.0",
|
|
4
4
|
"description": "Qdrant vector store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@qdrant/js-client-rest": "^1.
|
|
23
|
+
"@qdrant/js-client-rest": "^1.20.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "22.
|
|
27
|
-
"@vitest/coverage-v8": "4.1.
|
|
28
|
-
"@vitest/ui": "4.1.
|
|
29
|
-
"tsdown": "0.
|
|
30
|
-
"tsx": "^4.23.
|
|
26
|
+
"@types/node": "22.19.15",
|
|
27
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
28
|
+
"@vitest/ui": "4.1.12",
|
|
29
|
+
"tsdown": "0.23.1",
|
|
30
|
+
"tsx": "^4.23.15",
|
|
31
31
|
"typescript": "^7.0.2",
|
|
32
|
-
"vitest": "4.1.
|
|
33
|
-
"@internal/storage-test-utils": "0.0.141",
|
|
32
|
+
"vitest": "4.1.12",
|
|
34
33
|
"@internal/lint": "0.0.145",
|
|
34
|
+
"@internal/storage-test-utils": "0.0.141",
|
|
35
35
|
"@internal/types-builder": "0.0.120",
|
|
36
|
-
"@mastra/core": "1.
|
|
36
|
+
"@mastra/core": "1.80.0-alpha.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|