@memberjunction/ai-vectors-qdrant 0.0.1 → 5.24.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/README.md +217 -28
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/models/QdrantDatabase.d.ts +244 -0
- package/dist/models/QdrantDatabase.d.ts.map +1 -0
- package/dist/models/QdrantDatabase.js +652 -0
- package/dist/models/QdrantDatabase.js.map +1 -0
- package/package.json +31 -7
package/README.md
CHANGED
|
@@ -1,45 +1,234 @@
|
|
|
1
1
|
# @memberjunction/ai-vectors-qdrant
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MemberJunction vector database provider backed by [Qdrant](https://qdrant.tech/). Implements the `VectorDBBase` interface using the official `@qdrant/js-client-rest` client.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Prerequisites
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- A running Qdrant instance (local Docker container or Qdrant Cloud cluster)
|
|
8
|
+
- For Qdrant Cloud, an API key with appropriate permissions
|
|
8
9
|
|
|
9
|
-
##
|
|
10
|
+
## Installation
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
12
|
+
```bash
|
|
13
|
+
npm install @memberjunction/ai-vectors-qdrant
|
|
14
|
+
```
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## How It Works
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Each logical "index" maps to a **Qdrant collection**. A collection stores points, where each point consists of:
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
| Component | Description |
|
|
21
|
+
|---|---|
|
|
22
|
+
| **ID** | A string or integer identifier for the point |
|
|
23
|
+
| **Vector** | The embedding (dimension and distance metric are fixed at collection creation) |
|
|
24
|
+
| **Payload** | Arbitrary JSON key-value metadata stored alongside the vector |
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
When you call `CreateIndex`, the provider creates a Qdrant collection with the specified vector size and distance metric. You can pass additional Qdrant-specific collection parameters (e.g., HNSW config, quantization) via `params.additionalParams`.
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
+
Records are upserted via the Qdrant `upsert` operation, so calling `CreateRecord` or `CreateRecords` with an existing ID overwrites the previous point.
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
Queries use Qdrant's native ANN search. When a `vector` is provided, the provider calls `query()` directly. When only a point `id` is provided, the provider first retrieves that point's vector, then uses it as the query vector.
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
32
|
+
`DeleteAllRecords` works by deleting and recreating the collection with the same vector configuration, since Qdrant does not expose a single "truncate" operation.
|
|
36
33
|
|
|
37
|
-
##
|
|
34
|
+
## Supported Distance Metrics
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
| MJ Metric Value | Qdrant Distance | Description |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `cosine` (default) | `Cosine` | Cosine similarity (normalized dot product) |
|
|
39
|
+
| `euclidean` | `Euclid` | Euclidean (L2) distance |
|
|
40
|
+
| `dotproduct` | `Dot` | Dot product (inner product) |
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
The distance metric is set at collection creation time and cannot be changed afterward.
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
## Configuration
|
|
45
|
+
|
|
46
|
+
### Environment Variables
|
|
47
|
+
|
|
48
|
+
| Variable | Default | Description |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `QDRANT_URL` | `http://localhost:6333` | Qdrant server URL. For Qdrant Cloud, use the full cluster URL (e.g., `https://xyz.us-east-1-0.aws.cloud.qdrant.io:6333`). |
|
|
51
|
+
| `QDRANT_API_KEY` | *(none)* | API key for authentication. Required for Qdrant Cloud; optional for local instances. |
|
|
52
|
+
|
|
53
|
+
### Constructor
|
|
54
|
+
|
|
55
|
+
The `apiKey` constructor parameter is passed directly to the Qdrant client. If empty or `'default'`, no API key header is sent (suitable for local instances):
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Local instance (no auth)
|
|
59
|
+
const db = new QdrantDatabase('default');
|
|
60
|
+
|
|
61
|
+
// Qdrant Cloud
|
|
62
|
+
const db = new QdrantDatabase(process.env.QDRANT_API_KEY);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { QdrantDatabase } from '@memberjunction/ai-vectors-qdrant';
|
|
69
|
+
|
|
70
|
+
const db = new QdrantDatabase(process.env.QDRANT_API_KEY || 'default');
|
|
71
|
+
|
|
72
|
+
// Create a collection
|
|
73
|
+
await db.CreateIndex({
|
|
74
|
+
id: 'my-collection',
|
|
75
|
+
dimension: 1536,
|
|
76
|
+
metric: 'cosine',
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Upsert records
|
|
80
|
+
await db.CreateRecords([
|
|
81
|
+
{
|
|
82
|
+
id: 'vec-1',
|
|
83
|
+
values: [0.1, 0.2, ...],
|
|
84
|
+
metadata: { Entity: 'Documents', RecordID: '123' },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'vec-2',
|
|
88
|
+
values: [0.3, 0.4, ...],
|
|
89
|
+
metadata: { Entity: 'Documents', RecordID: '456' },
|
|
90
|
+
},
|
|
91
|
+
], 'my-collection');
|
|
92
|
+
|
|
93
|
+
// Query by vector similarity
|
|
94
|
+
const results = await db.QueryIndex({
|
|
95
|
+
id: 'my-collection',
|
|
96
|
+
vector: [0.1, 0.2, ...],
|
|
97
|
+
topK: 10,
|
|
98
|
+
includeMetadata: true,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// List all collections
|
|
102
|
+
const indexes = await db.ListIndexes();
|
|
103
|
+
|
|
104
|
+
// Get collection details (dimension, metric)
|
|
105
|
+
const info = await db.GetIndex({ id: 'my-collection' });
|
|
106
|
+
|
|
107
|
+
// Delete specific records
|
|
108
|
+
await db.DeleteRecords(
|
|
109
|
+
[{ id: 'vec-1', values: [] }],
|
|
110
|
+
'my-collection'
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// Delete all records (drops and recreates the collection)
|
|
114
|
+
await db.DeleteAllRecords('my-collection');
|
|
115
|
+
|
|
116
|
+
// Delete the collection entirely
|
|
117
|
+
await db.DeleteIndex({ id: 'my-collection' });
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Metadata Filtering
|
|
121
|
+
|
|
122
|
+
Qdrant uses a structured filter format with `must`, `should`, and `must_not` clauses. This provider supports two approaches for building filters.
|
|
123
|
+
|
|
124
|
+
### SharedIndexFilterOptions (Cross-Provider)
|
|
125
|
+
|
|
126
|
+
The recommended approach uses `BuildMetadataFilter()`, which accepts the provider-agnostic `SharedIndexFilterOptions` interface and produces a Qdrant-native filter:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
const filter = db.BuildMetadataFilter({
|
|
130
|
+
EntityName: 'Documents',
|
|
131
|
+
RecordIDs: ['rec-1', 'rec-2'],
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const results = await db.QueryIndex({
|
|
135
|
+
id: 'my-collection',
|
|
136
|
+
vector: [...],
|
|
137
|
+
topK: 10,
|
|
138
|
+
filter,
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Under the hood, `BuildMetadataFilter` performs the following mapping:
|
|
143
|
+
|
|
144
|
+
| SharedIndexFilterOptions field | Qdrant filter clause |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `EntityName` | `must: [{ key: "Entity", match: { value: "Documents" } }]` |
|
|
147
|
+
| `RecordIDs` (single value) | `must: [{ key: "RecordID", match: { value: "rec-1" } }]` |
|
|
148
|
+
| `RecordIDs` (multiple values) | `must: [{ key: "RecordID", match: { any: ["rec-1", "rec-2"] } }]` |
|
|
149
|
+
| Additional conditions via `VectorMetadataFilter.BuildConditions` | Mapped with `eq` -> `match.value`, `in` -> `match.any`, `contains` -> `match.value` |
|
|
150
|
+
|
|
151
|
+
All conditions are combined into a single `must` array (AND logic).
|
|
152
|
+
|
|
153
|
+
### Qdrant-Native Filters
|
|
154
|
+
|
|
155
|
+
You can also pass Qdrant's native filter syntax directly as the `filter` property on `QueryIndex`:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
const results = await db.QueryIndex({
|
|
159
|
+
id: 'my-collection',
|
|
160
|
+
vector: [...],
|
|
161
|
+
topK: 10,
|
|
162
|
+
filter: {
|
|
163
|
+
must: [
|
|
164
|
+
{ key: 'category', match: { value: 'science' } },
|
|
165
|
+
{ key: 'year', range: { gte: 2020 } },
|
|
166
|
+
],
|
|
167
|
+
must_not: [
|
|
168
|
+
{ key: 'status', match: { value: 'archived' } },
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
This gives you full access to Qdrant's filtering capabilities including range filters, geo filters, and nested conditions. See the [Qdrant filtering documentation](https://qdrant.tech/documentation/concepts/filtering/) for the complete filter syntax.
|
|
175
|
+
|
|
176
|
+
## Record Operations
|
|
177
|
+
|
|
178
|
+
### GetRecord / GetRecords
|
|
179
|
+
|
|
180
|
+
To retrieve points by ID, pass the collection name in `params.data`:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
const result = await db.GetRecords({
|
|
184
|
+
id: 'ignored',
|
|
185
|
+
data: {
|
|
186
|
+
collectionName: 'my-collection',
|
|
187
|
+
ids: ['vec-1', 'vec-2'],
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### UpdateRecord / UpdateRecords
|
|
193
|
+
|
|
194
|
+
Updates use upsert for records with vectors and `setPayload` for metadata-only updates:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
await db.UpdateRecord({
|
|
198
|
+
id: 'vec-1',
|
|
199
|
+
values: [0.5, 0.6, ...], // new vector (uses upsert)
|
|
200
|
+
metadata: { status: 'updated' },
|
|
201
|
+
data: { collectionName: 'my-collection' },
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Metadata-only update (no vector change)
|
|
205
|
+
await db.UpdateRecord({
|
|
206
|
+
id: 'vec-1',
|
|
207
|
+
metadata: { status: 'reviewed' },
|
|
208
|
+
data: { collectionName: 'my-collection' },
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### EditIndex
|
|
213
|
+
|
|
214
|
+
Qdrant supports updating collection-level parameters (optimizer settings, etc.) via `EditIndex`:
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
await db.EditIndex({
|
|
218
|
+
id: 'my-collection',
|
|
219
|
+
data: {
|
|
220
|
+
optimizers_config: {
|
|
221
|
+
indexing_threshold: 20000,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Limitations
|
|
228
|
+
|
|
229
|
+
- **No hybrid search**: The `SupportsHybridSearch` property is not overridden and defaults to the base class behavior. Pure vector search only.
|
|
230
|
+
- **ListIndexes dimension/metric**: The `ListIndexes` method returns `dimension: 0` and `metric: 'cosine'` for all collections because the Qdrant list endpoint does not return per-collection vector configuration. Use `GetIndex` for accurate details.
|
|
231
|
+
- **DeleteAllRecords is destructive**: The collection is dropped and recreated, which resets all optimizer and indexing state.
|
|
232
|
+
- **String IDs only**: While Qdrant supports both string and integer point IDs, the MJ interface uses string IDs throughout. Integer IDs are converted to strings in results.
|
|
233
|
+
- **Single vector per point**: Named vector configurations are not currently exposed; only the default (unnamed) vector is used.
|
|
234
|
+
- **No namespace support**: Qdrant does not have a namespace concept. The `namespace` parameter on `DeleteAllRecords` is ignored.
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qdrant connection URL. Defaults to localhost:6333 if not set.
|
|
3
|
+
* For Qdrant Cloud, use the full cluster URL (e.g., https://xyz.us-east-1-0.aws.cloud.qdrant.io:6333).
|
|
4
|
+
*/
|
|
5
|
+
export declare const qdrantUrl: string;
|
|
6
|
+
/**
|
|
7
|
+
* Qdrant API key. Required for Qdrant Cloud; optional for local instances.
|
|
8
|
+
*/
|
|
9
|
+
export declare const qdrantApiKey: string | undefined;
|
|
10
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,MAA0D,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,GAAG,SAAsC,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config({ quiet: true });
|
|
3
|
+
/**
|
|
4
|
+
* Qdrant connection URL. Defaults to localhost:6333 if not set.
|
|
5
|
+
* For Qdrant Cloud, use the full cluster URL (e.g., https://xyz.us-east-1-0.aws.cloud.qdrant.io:6333).
|
|
6
|
+
*/
|
|
7
|
+
export const qdrantUrl = process.env.QDRANT_URL || 'http://localhost:6333';
|
|
8
|
+
/**
|
|
9
|
+
* Qdrant API key. Required for Qdrant Cloud; optional for local instances.
|
|
10
|
+
*/
|
|
11
|
+
export const qdrantApiKey = process.env.QDRANT_API_KEY;
|
|
12
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAE/B;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAW,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,uBAAuB,CAAC;AAEnF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAuB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { QdrantClient } from '@qdrant/js-client-rest';
|
|
2
|
+
import { BaseRequestParams, BaseResponse, CreateIndexParams, EditIndexParams, IndexList, ListVectorIDsParams, ListVectorIDsResult, SharedIndexFilterOptions, VectorDBBase, VectorRecord, UpdateOptions, QueryOptions as MJQueryOptions } from '@memberjunction/ai-vectordb';
|
|
3
|
+
/**
|
|
4
|
+
* MemberJunction vector database provider backed by [Qdrant](https://qdrant.tech/),
|
|
5
|
+
* a high-performance open-source vector similarity search engine.
|
|
6
|
+
*
|
|
7
|
+
* **How it works:** Each logical "index" maps to a Qdrant **collection**. A collection
|
|
8
|
+
* stores points consisting of an ID, a dense vector embedding, and an arbitrary JSON
|
|
9
|
+
* payload (metadata). The provider uses the official `@qdrant/js-client-rest` client
|
|
10
|
+
* for all communication with the Qdrant server.
|
|
11
|
+
*
|
|
12
|
+
* **Connection:** Configure the server URL via `QDRANT_URL` (defaults to
|
|
13
|
+
* `http://localhost:6333`) and optionally an API key via `QDRANT_API_KEY` (required
|
|
14
|
+
* for Qdrant Cloud). The `apiKey` constructor parameter is forwarded directly to the
|
|
15
|
+
* Qdrant client.
|
|
16
|
+
*
|
|
17
|
+
* **Distance metrics:** Supports `cosine` (default), `euclidean`, and `dotproduct`,
|
|
18
|
+
* mapped to Qdrant's `Cosine`, `Euclid`, and `Dot` distance types respectively.
|
|
19
|
+
*
|
|
20
|
+
* **Metadata filtering:** Supports both Qdrant-native `must`/`should`/`must_not`
|
|
21
|
+
* filter syntax and the shared `SharedIndexFilterOptions` interface used across all
|
|
22
|
+
* MJ vector providers. Conditions are converted to Qdrant's structured filter format
|
|
23
|
+
* via {@link BuildMetadataFilter}.
|
|
24
|
+
*
|
|
25
|
+
* Registered with the MJ class factory as `'QdrantDatabase'`.
|
|
26
|
+
*/
|
|
27
|
+
export declare class QdrantDatabase extends VectorDBBase {
|
|
28
|
+
private _client;
|
|
29
|
+
constructor(apiKey: string);
|
|
30
|
+
/**
|
|
31
|
+
* Access the underlying Qdrant client for advanced operations.
|
|
32
|
+
*/
|
|
33
|
+
get Client(): QdrantClient;
|
|
34
|
+
/**
|
|
35
|
+
* List all collections (indexes) in the connected Qdrant instance.
|
|
36
|
+
*
|
|
37
|
+
* Note: The Qdrant list endpoint does not return per-collection vector configuration,
|
|
38
|
+
* so `dimension` is reported as `0` and `metric` as `'cosine'` for every entry.
|
|
39
|
+
* Use {@link GetIndex} for accurate details.
|
|
40
|
+
*
|
|
41
|
+
* @returns An {@link IndexList} containing descriptions of every collection.
|
|
42
|
+
* Returns an empty list on error.
|
|
43
|
+
*/
|
|
44
|
+
ListIndexes(): Promise<IndexList>;
|
|
45
|
+
/**
|
|
46
|
+
* Get detailed information about a specific collection including its actual
|
|
47
|
+
* dimension and distance metric.
|
|
48
|
+
*
|
|
49
|
+
* @param params - Request parameters; `params.id` must be the collection name.
|
|
50
|
+
* @returns A {@link BaseResponse} whose `data` is an {@link IndexDescription} on success,
|
|
51
|
+
* or a failure response if the collection does not exist.
|
|
52
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
53
|
+
*/
|
|
54
|
+
GetIndex(params: BaseRequestParams): Promise<BaseResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Create a new Qdrant collection with the specified vector configuration.
|
|
57
|
+
*
|
|
58
|
+
* Additional Qdrant-specific collection parameters (e.g., HNSW config,
|
|
59
|
+
* quantization, replication factor) can be passed via `params.additionalParams`.
|
|
60
|
+
*
|
|
61
|
+
* @param params - Index creation parameters including `id` (collection name),
|
|
62
|
+
* `dimension` (vector size), `metric` (distance type), and optional
|
|
63
|
+
* `additionalParams` for Qdrant-specific settings.
|
|
64
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
65
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
66
|
+
*/
|
|
67
|
+
CreateIndex(params: CreateIndexParams): Promise<BaseResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Delete a Qdrant collection and all its points permanently.
|
|
70
|
+
*
|
|
71
|
+
* @param params - Request parameters; `params.id` must be the collection name.
|
|
72
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
73
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
74
|
+
*/
|
|
75
|
+
DeleteIndex(params: BaseRequestParams): Promise<BaseResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Update collection-level parameters such as optimizer configuration and indexing
|
|
78
|
+
* thresholds. Pass Qdrant-specific update parameters via `params.data`.
|
|
79
|
+
*
|
|
80
|
+
* @param params - Edit parameters; `params.id` is the collection name and `params.data`
|
|
81
|
+
* contains the Qdrant `updateCollection` payload.
|
|
82
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
83
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
84
|
+
*/
|
|
85
|
+
EditIndex(params: EditIndexParams): Promise<BaseResponse>;
|
|
86
|
+
/**
|
|
87
|
+
* Perform an approximate nearest-neighbor search against a Qdrant collection.
|
|
88
|
+
*
|
|
89
|
+
* Two query modes are supported:
|
|
90
|
+
* - **By vector**: When `params.vector` is provided, searches directly with that vector.
|
|
91
|
+
* `params.id` is interpreted as the collection name.
|
|
92
|
+
* - **By point ID**: When only `params.id` is provided, retrieves the point's vector
|
|
93
|
+
* first, then uses it as the query vector.
|
|
94
|
+
*
|
|
95
|
+
* @param params - Query options including:
|
|
96
|
+
* - `vector` (number[]) -- the query embedding.
|
|
97
|
+
* - `id` (string) -- collection name (when vector is present) or point ID.
|
|
98
|
+
* - `topK` (number) -- maximum results to return (default 10).
|
|
99
|
+
* - `includeMetadata` (boolean) -- include payload in results (default true).
|
|
100
|
+
* - `includeValues` (boolean) -- include vectors in results (default false).
|
|
101
|
+
* - `filter` (object) -- optional Qdrant-native filter.
|
|
102
|
+
* @returns A {@link BaseResponse} whose `data` contains `{ matches, namespace }`,
|
|
103
|
+
* or a failure response on error.
|
|
104
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
105
|
+
*/
|
|
106
|
+
QueryIndex(params: MJQueryOptions): Promise<BaseResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* Insert or update a single vector record (point) into a collection.
|
|
109
|
+
* Delegates to {@link CreateRecords} with a single-element array.
|
|
110
|
+
*
|
|
111
|
+
* @param record - The vector record to upsert (id, values, and optional metadata).
|
|
112
|
+
* @param indexName - The target collection name. Required.
|
|
113
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
114
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
115
|
+
*/
|
|
116
|
+
CreateRecord(record: VectorRecord, indexName?: string): Promise<BaseResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* Insert or update multiple vector records (points) into a collection via upsert.
|
|
119
|
+
*
|
|
120
|
+
* @param records - Array of vector records to upsert.
|
|
121
|
+
* @param indexName - The target collection name. Required.
|
|
122
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
123
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
124
|
+
*/
|
|
125
|
+
CreateRecords(records: VectorRecord[], indexName?: string): Promise<BaseResponse>;
|
|
126
|
+
/**
|
|
127
|
+
* Retrieve a single point by ID. Delegates to {@link GetRecords}.
|
|
128
|
+
*
|
|
129
|
+
* @param params - Request parameters. `params.id` is the point ID and
|
|
130
|
+
* `params.data.collectionName` identifies the target collection. Both are required.
|
|
131
|
+
* @returns A {@link BaseResponse} whose `data` is an array of {@link VectorRecord}
|
|
132
|
+
* objects on success, or a failure response on error.
|
|
133
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
134
|
+
*/
|
|
135
|
+
GetRecord(params: BaseRequestParams): Promise<BaseResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Retrieve multiple points by their IDs from a Qdrant collection.
|
|
138
|
+
*
|
|
139
|
+
* @param params - Request parameters. `params.data.collectionName` is the target
|
|
140
|
+
* collection and `params.data.ids` is the array of point IDs to retrieve.
|
|
141
|
+
* If `ids` is not provided, `params.id` is used as a single-element list.
|
|
142
|
+
* @returns A {@link BaseResponse} whose `data` is an array of {@link VectorRecord}
|
|
143
|
+
* objects on success, or a failure response on error.
|
|
144
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
145
|
+
*/
|
|
146
|
+
GetRecords(params: BaseRequestParams): Promise<BaseResponse>;
|
|
147
|
+
/**
|
|
148
|
+
* Update a single record. Delegates to {@link UpdateRecords}.
|
|
149
|
+
*
|
|
150
|
+
* If the record includes `values`, the point is upserted (vector + payload replaced).
|
|
151
|
+
* If only `metadata` is provided (no `values`), the payload is updated in place
|
|
152
|
+
* via Qdrant's `setPayload` operation without touching the vector.
|
|
153
|
+
*
|
|
154
|
+
* @param record - Update options including `id`, optional `values`, optional `metadata`,
|
|
155
|
+
* and `data.collectionName` (required).
|
|
156
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
157
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
158
|
+
*/
|
|
159
|
+
UpdateRecord(record: UpdateOptions): Promise<BaseResponse>;
|
|
160
|
+
/**
|
|
161
|
+
* Update one or more records in a Qdrant collection.
|
|
162
|
+
*
|
|
163
|
+
* Records with `values` are upserted (full point replacement). Records with only
|
|
164
|
+
* `metadata` (no `values`) are updated via `setPayload` to modify the payload
|
|
165
|
+
* without changing the vector.
|
|
166
|
+
*
|
|
167
|
+
* @param records - Update options. Must include `data.collectionName`. For batch
|
|
168
|
+
* operations, provide `data.records` as an array of individual update options.
|
|
169
|
+
* For single-record updates, the top-level id/values/metadata are used.
|
|
170
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
171
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
172
|
+
*/
|
|
173
|
+
UpdateRecords(records: UpdateOptions): Promise<BaseResponse>;
|
|
174
|
+
/**
|
|
175
|
+
* Delete a single point from a Qdrant collection.
|
|
176
|
+
* Delegates to {@link DeleteRecords} with a single-element array.
|
|
177
|
+
*
|
|
178
|
+
* @param record - The record to delete; only `record.id` is used.
|
|
179
|
+
* @param indexName - The target collection name. Required.
|
|
180
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
181
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
182
|
+
*/
|
|
183
|
+
DeleteRecord(record: VectorRecord, indexName?: string): Promise<BaseResponse>;
|
|
184
|
+
/**
|
|
185
|
+
* Delete multiple points from a Qdrant collection in a single batch operation.
|
|
186
|
+
*
|
|
187
|
+
* @param records - The records to delete; only their `id` fields are used.
|
|
188
|
+
* @param indexName - The target collection name. Required.
|
|
189
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
190
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
191
|
+
*/
|
|
192
|
+
DeleteRecords(records: VectorRecord[], indexName?: string): Promise<BaseResponse>;
|
|
193
|
+
/**
|
|
194
|
+
* Delete **all** points from a collection by dropping and recreating it with the
|
|
195
|
+
* same vector configuration. Qdrant does not expose a native "truncate" operation.
|
|
196
|
+
*
|
|
197
|
+
* Warning: This resets all optimizer and indexing state for the collection.
|
|
198
|
+
*
|
|
199
|
+
* @param indexName - The target collection name.
|
|
200
|
+
* @param _namespace - Ignored; Qdrant does not use namespaces.
|
|
201
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
202
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
203
|
+
*/
|
|
204
|
+
DeleteAllRecords(indexName: string, _namespace?: string): Promise<BaseResponse>;
|
|
205
|
+
/**
|
|
206
|
+
* List vector IDs using Qdrant's scroll API with optional metadata filtering
|
|
207
|
+
* and cursor-based pagination.
|
|
208
|
+
*
|
|
209
|
+
* @param params - Parameters including `IndexName` (collection name), optional `Limit`
|
|
210
|
+
* (default 100), optional `PaginationToken` (Qdrant scroll offset from a
|
|
211
|
+
* previous call), and optional `MetadataFilter` (key-value pairs translated
|
|
212
|
+
* to Qdrant `must` match conditions).
|
|
213
|
+
* @returns A {@link ListVectorIDsResult} with the matching IDs and an optional
|
|
214
|
+
* `NextPaginationToken` for the next page.
|
|
215
|
+
* @throws Never throws; errors are caught and an empty result is returned.
|
|
216
|
+
*/
|
|
217
|
+
ListVectorIDs(params: ListVectorIDsParams): Promise<ListVectorIDsResult>;
|
|
218
|
+
/**
|
|
219
|
+
* Build a Qdrant-native filter from the shared {@link SharedIndexFilterOptions}
|
|
220
|
+
* interface used across all MJ vector providers.
|
|
221
|
+
*
|
|
222
|
+
* The shared filter options (EntityName, RecordIDs, etc.) are first converted to
|
|
223
|
+
* generic {@link MetadataFilterCondition} objects via `VectorMetadataFilter.BuildConditions`,
|
|
224
|
+
* then translated into Qdrant's structured filter format. The resulting filter uses
|
|
225
|
+
* `must` clauses with `match.value` for equality and `match.any` for set membership.
|
|
226
|
+
*
|
|
227
|
+
* @param options - The provider-agnostic filter options.
|
|
228
|
+
* @returns A Qdrant filter object suitable for passing as `QueryOptions.filter`,
|
|
229
|
+
* or `undefined` if the options produce no conditions.
|
|
230
|
+
*/
|
|
231
|
+
BuildMetadataFilter(options: SharedIndexFilterOptions): object | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* Convert MetadataFilterConditions to Qdrant's native filter syntax.
|
|
234
|
+
*/
|
|
235
|
+
private ConditionsToQdrantFilter;
|
|
236
|
+
/**
|
|
237
|
+
* Extract collection name from query params. Checks for 'id' field first (used as collection name
|
|
238
|
+
* when vector is also provided), otherwise returns undefined.
|
|
239
|
+
*/
|
|
240
|
+
private ExtractCollectionName;
|
|
241
|
+
private WrapSuccessResponse;
|
|
242
|
+
private WrapFailureResponse;
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=QdrantDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QdrantDatabase.d.ts","sourceRoot":"","sources":["../../src/models/QdrantDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACH,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EAEf,SAAS,EAET,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EAEZ,YAAY,EACZ,aAAa,EACb,YAAY,IAAI,cAAc,EAEjC,MAAM,6BAA6B,CAAC;AAoCrC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,cAAe,SAAQ,YAAY;IAC5C,OAAO,CAAC,OAAO,CAAe;gBAElB,MAAM,EAAE,MAAM;IAQ1B;;OAEG;IACH,IAAI,MAAM,IAAI,YAAY,CAEzB;IAED;;;;;;;;;OASG;IACU,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC;IAgB9C;;;;;;;;OAQG;IACU,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IA6BvE;;;;;;;;;;;OAWG;IACU,WAAW,CAAC,MAAM,EAAE,iBAA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AAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAuB5F;;;;;;;;;;;OAWG;IACU,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA6CrF;;;;;;;;;;;;OAYG;IACa,mBAAmB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,GAAG,SAAS;IAQ1F;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAoChC;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAiB7B,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,mBAAmB;CAO9B"}
|
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { QdrantClient } from '@qdrant/js-client-rest';
|
|
11
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
12
|
+
import { VectorDBBase, VectorMetadataFilter, } from '@memberjunction/ai-vectordb';
|
|
13
|
+
import { LogError } from '@memberjunction/core';
|
|
14
|
+
import { qdrantUrl } from '../config.js';
|
|
15
|
+
/**
|
|
16
|
+
* Maps MJ's metric enum values to Qdrant distance types.
|
|
17
|
+
*/
|
|
18
|
+
function mjMetricToQdrantDistance(metric) {
|
|
19
|
+
switch (metric) {
|
|
20
|
+
case 'cosine':
|
|
21
|
+
return 'Cosine';
|
|
22
|
+
case 'euclidean':
|
|
23
|
+
return 'Euclid';
|
|
24
|
+
case 'dotproduct':
|
|
25
|
+
return 'Dot';
|
|
26
|
+
default:
|
|
27
|
+
return 'Cosine';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Maps Qdrant distance types back to MJ's metric enum values.
|
|
32
|
+
*/
|
|
33
|
+
function qdrantDistanceToMJMetric(distance) {
|
|
34
|
+
switch (distance) {
|
|
35
|
+
case 'Cosine':
|
|
36
|
+
return 'cosine';
|
|
37
|
+
case 'Euclid':
|
|
38
|
+
return 'euclidean';
|
|
39
|
+
case 'Dot':
|
|
40
|
+
return 'dotproduct';
|
|
41
|
+
default:
|
|
42
|
+
return 'cosine';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* MemberJunction vector database provider backed by [Qdrant](https://qdrant.tech/),
|
|
47
|
+
* a high-performance open-source vector similarity search engine.
|
|
48
|
+
*
|
|
49
|
+
* **How it works:** Each logical "index" maps to a Qdrant **collection**. A collection
|
|
50
|
+
* stores points consisting of an ID, a dense vector embedding, and an arbitrary JSON
|
|
51
|
+
* payload (metadata). The provider uses the official `@qdrant/js-client-rest` client
|
|
52
|
+
* for all communication with the Qdrant server.
|
|
53
|
+
*
|
|
54
|
+
* **Connection:** Configure the server URL via `QDRANT_URL` (defaults to
|
|
55
|
+
* `http://localhost:6333`) and optionally an API key via `QDRANT_API_KEY` (required
|
|
56
|
+
* for Qdrant Cloud). The `apiKey` constructor parameter is forwarded directly to the
|
|
57
|
+
* Qdrant client.
|
|
58
|
+
*
|
|
59
|
+
* **Distance metrics:** Supports `cosine` (default), `euclidean`, and `dotproduct`,
|
|
60
|
+
* mapped to Qdrant's `Cosine`, `Euclid`, and `Dot` distance types respectively.
|
|
61
|
+
*
|
|
62
|
+
* **Metadata filtering:** Supports both Qdrant-native `must`/`should`/`must_not`
|
|
63
|
+
* filter syntax and the shared `SharedIndexFilterOptions` interface used across all
|
|
64
|
+
* MJ vector providers. Conditions are converted to Qdrant's structured filter format
|
|
65
|
+
* via {@link BuildMetadataFilter}.
|
|
66
|
+
*
|
|
67
|
+
* Registered with the MJ class factory as `'QdrantDatabase'`.
|
|
68
|
+
*/
|
|
69
|
+
let QdrantDatabase = class QdrantDatabase extends VectorDBBase {
|
|
70
|
+
constructor(apiKey) {
|
|
71
|
+
super(apiKey);
|
|
72
|
+
this._client = new QdrantClient({
|
|
73
|
+
url: qdrantUrl,
|
|
74
|
+
apiKey: apiKey || undefined,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Access the underlying Qdrant client for advanced operations.
|
|
79
|
+
*/
|
|
80
|
+
get Client() {
|
|
81
|
+
return this._client;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* List all collections (indexes) in the connected Qdrant instance.
|
|
85
|
+
*
|
|
86
|
+
* Note: The Qdrant list endpoint does not return per-collection vector configuration,
|
|
87
|
+
* so `dimension` is reported as `0` and `metric` as `'cosine'` for every entry.
|
|
88
|
+
* Use {@link GetIndex} for accurate details.
|
|
89
|
+
*
|
|
90
|
+
* @returns An {@link IndexList} containing descriptions of every collection.
|
|
91
|
+
* Returns an empty list on error.
|
|
92
|
+
*/
|
|
93
|
+
async ListIndexes() {
|
|
94
|
+
try {
|
|
95
|
+
const response = await this._client.getCollections();
|
|
96
|
+
const indexes = response.collections.map((c) => ({
|
|
97
|
+
name: c.name,
|
|
98
|
+
dimension: 0, // Not available from list endpoint
|
|
99
|
+
metric: 'cosine',
|
|
100
|
+
host: qdrantUrl,
|
|
101
|
+
}));
|
|
102
|
+
return { indexes };
|
|
103
|
+
}
|
|
104
|
+
catch (ex) {
|
|
105
|
+
LogError('Error listing Qdrant collections', undefined, ex);
|
|
106
|
+
return { indexes: [] };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get detailed information about a specific collection including its actual
|
|
111
|
+
* dimension and distance metric.
|
|
112
|
+
*
|
|
113
|
+
* @param params - Request parameters; `params.id` must be the collection name.
|
|
114
|
+
* @returns A {@link BaseResponse} whose `data` is an {@link IndexDescription} on success,
|
|
115
|
+
* or a failure response if the collection does not exist.
|
|
116
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
117
|
+
*/
|
|
118
|
+
async GetIndex(params) {
|
|
119
|
+
try {
|
|
120
|
+
const info = await this._client.getCollection(params.id);
|
|
121
|
+
const vectorsConfig = info.config?.params?.vectors;
|
|
122
|
+
let dimension = 0;
|
|
123
|
+
let metric = 'cosine';
|
|
124
|
+
// Handle both named and unnamed vector configs
|
|
125
|
+
if (vectorsConfig && typeof vectorsConfig === 'object' && 'size' in vectorsConfig) {
|
|
126
|
+
const vc = vectorsConfig;
|
|
127
|
+
dimension = vc.size;
|
|
128
|
+
metric = qdrantDistanceToMJMetric(vc.distance);
|
|
129
|
+
}
|
|
130
|
+
const description = {
|
|
131
|
+
name: params.id,
|
|
132
|
+
dimension,
|
|
133
|
+
metric,
|
|
134
|
+
host: qdrantUrl,
|
|
135
|
+
};
|
|
136
|
+
return this.WrapSuccessResponse(description);
|
|
137
|
+
}
|
|
138
|
+
catch (ex) {
|
|
139
|
+
LogError('Error getting Qdrant collection', undefined, ex);
|
|
140
|
+
return this.WrapFailureResponse(`Failed to get collection: ${params.id}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Create a new Qdrant collection with the specified vector configuration.
|
|
145
|
+
*
|
|
146
|
+
* Additional Qdrant-specific collection parameters (e.g., HNSW config,
|
|
147
|
+
* quantization, replication factor) can be passed via `params.additionalParams`.
|
|
148
|
+
*
|
|
149
|
+
* @param params - Index creation parameters including `id` (collection name),
|
|
150
|
+
* `dimension` (vector size), `metric` (distance type), and optional
|
|
151
|
+
* `additionalParams` for Qdrant-specific settings.
|
|
152
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
153
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
154
|
+
*/
|
|
155
|
+
async CreateIndex(params) {
|
|
156
|
+
try {
|
|
157
|
+
const distance = mjMetricToQdrantDistance(params.metric);
|
|
158
|
+
await this._client.createCollection(params.id, {
|
|
159
|
+
vectors: {
|
|
160
|
+
size: params.dimension,
|
|
161
|
+
distance: distance,
|
|
162
|
+
},
|
|
163
|
+
...(params.additionalParams || {}),
|
|
164
|
+
});
|
|
165
|
+
return this.WrapSuccessResponse(null);
|
|
166
|
+
}
|
|
167
|
+
catch (ex) {
|
|
168
|
+
LogError('Error creating Qdrant collection', undefined, ex);
|
|
169
|
+
return this.WrapFailureResponse(`Failed to create collection: ${params.id}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Delete a Qdrant collection and all its points permanently.
|
|
174
|
+
*
|
|
175
|
+
* @param params - Request parameters; `params.id` must be the collection name.
|
|
176
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
177
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
178
|
+
*/
|
|
179
|
+
async DeleteIndex(params) {
|
|
180
|
+
try {
|
|
181
|
+
await this._client.deleteCollection(params.id);
|
|
182
|
+
return this.WrapSuccessResponse(null);
|
|
183
|
+
}
|
|
184
|
+
catch (ex) {
|
|
185
|
+
LogError('Error deleting Qdrant collection', undefined, ex);
|
|
186
|
+
return this.WrapFailureResponse(`Failed to delete collection: ${params.id}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Update collection-level parameters such as optimizer configuration and indexing
|
|
191
|
+
* thresholds. Pass Qdrant-specific update parameters via `params.data`.
|
|
192
|
+
*
|
|
193
|
+
* @param params - Edit parameters; `params.id` is the collection name and `params.data`
|
|
194
|
+
* contains the Qdrant `updateCollection` payload.
|
|
195
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
196
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
197
|
+
*/
|
|
198
|
+
async EditIndex(params) {
|
|
199
|
+
try {
|
|
200
|
+
await this._client.updateCollection(params.id, {
|
|
201
|
+
...(params.data || {}),
|
|
202
|
+
});
|
|
203
|
+
return this.WrapSuccessResponse(null);
|
|
204
|
+
}
|
|
205
|
+
catch (ex) {
|
|
206
|
+
LogError('Error updating Qdrant collection', undefined, ex);
|
|
207
|
+
return this.WrapFailureResponse(`Failed to update collection: ${params.id}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Perform an approximate nearest-neighbor search against a Qdrant collection.
|
|
212
|
+
*
|
|
213
|
+
* Two query modes are supported:
|
|
214
|
+
* - **By vector**: When `params.vector` is provided, searches directly with that vector.
|
|
215
|
+
* `params.id` is interpreted as the collection name.
|
|
216
|
+
* - **By point ID**: When only `params.id` is provided, retrieves the point's vector
|
|
217
|
+
* first, then uses it as the query vector.
|
|
218
|
+
*
|
|
219
|
+
* @param params - Query options including:
|
|
220
|
+
* - `vector` (number[]) -- the query embedding.
|
|
221
|
+
* - `id` (string) -- collection name (when vector is present) or point ID.
|
|
222
|
+
* - `topK` (number) -- maximum results to return (default 10).
|
|
223
|
+
* - `includeMetadata` (boolean) -- include payload in results (default true).
|
|
224
|
+
* - `includeValues` (boolean) -- include vectors in results (default false).
|
|
225
|
+
* - `filter` (object) -- optional Qdrant-native filter.
|
|
226
|
+
* @returns A {@link BaseResponse} whose `data` contains `{ matches, namespace }`,
|
|
227
|
+
* or a failure response on error.
|
|
228
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
229
|
+
*/
|
|
230
|
+
async QueryIndex(params) {
|
|
231
|
+
try {
|
|
232
|
+
const collectionName = this.ExtractCollectionName(params);
|
|
233
|
+
if (!collectionName) {
|
|
234
|
+
return this.WrapFailureResponse('Collection name (id) is required for QueryIndex');
|
|
235
|
+
}
|
|
236
|
+
const limit = params.topK || 10;
|
|
237
|
+
const includePayload = params.includeMetadata !== false;
|
|
238
|
+
const includeVectors = params.includeValues === true;
|
|
239
|
+
let scoredPoints;
|
|
240
|
+
if ('vector' in params && params.vector) {
|
|
241
|
+
const response = await this._client.query(collectionName, {
|
|
242
|
+
query: params.vector,
|
|
243
|
+
limit,
|
|
244
|
+
with_payload: includePayload,
|
|
245
|
+
with_vector: includeVectors,
|
|
246
|
+
...(params.filter ? { filter: params.filter } : {}),
|
|
247
|
+
});
|
|
248
|
+
scoredPoints = response.points;
|
|
249
|
+
}
|
|
250
|
+
else if ('id' in params && params.id) {
|
|
251
|
+
// Query by point ID: retrieve the point, then search with its vector
|
|
252
|
+
const points = await this._client.retrieve(collectionName, {
|
|
253
|
+
ids: [params.id],
|
|
254
|
+
with_vector: true,
|
|
255
|
+
});
|
|
256
|
+
if (points.length === 0) {
|
|
257
|
+
return this.WrapFailureResponse(`Point not found: ${params.id}`);
|
|
258
|
+
}
|
|
259
|
+
const pointVector = points[0].vector;
|
|
260
|
+
if (!pointVector || !Array.isArray(pointVector)) {
|
|
261
|
+
return this.WrapFailureResponse('Point does not have a vector for querying');
|
|
262
|
+
}
|
|
263
|
+
const response = await this._client.query(collectionName, {
|
|
264
|
+
query: pointVector,
|
|
265
|
+
limit,
|
|
266
|
+
with_payload: includePayload,
|
|
267
|
+
with_vector: includeVectors,
|
|
268
|
+
...(params.filter ? { filter: params.filter } : {}),
|
|
269
|
+
});
|
|
270
|
+
scoredPoints = response.points;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
return this.WrapFailureResponse('Either vector or id is required for QueryIndex');
|
|
274
|
+
}
|
|
275
|
+
// Map Qdrant results to our standard format
|
|
276
|
+
const matches = (scoredPoints || []).map((r) => ({
|
|
277
|
+
id: String(r.id),
|
|
278
|
+
values: Array.isArray(r.vector) ? r.vector : [],
|
|
279
|
+
metadata: r.payload || {},
|
|
280
|
+
score: r.score,
|
|
281
|
+
}));
|
|
282
|
+
return this.WrapSuccessResponse({
|
|
283
|
+
matches,
|
|
284
|
+
namespace: '',
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
catch (ex) {
|
|
288
|
+
LogError('Error querying Qdrant collection', undefined, ex);
|
|
289
|
+
return this.WrapFailureResponse('Failed to query collection');
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Insert or update a single vector record (point) into a collection.
|
|
294
|
+
* Delegates to {@link CreateRecords} with a single-element array.
|
|
295
|
+
*
|
|
296
|
+
* @param record - The vector record to upsert (id, values, and optional metadata).
|
|
297
|
+
* @param indexName - The target collection name. Required.
|
|
298
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
299
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
300
|
+
*/
|
|
301
|
+
async CreateRecord(record, indexName) {
|
|
302
|
+
return this.CreateRecords([record], indexName);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Insert or update multiple vector records (points) into a collection via upsert.
|
|
306
|
+
*
|
|
307
|
+
* @param records - Array of vector records to upsert.
|
|
308
|
+
* @param indexName - The target collection name. Required.
|
|
309
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
310
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
311
|
+
*/
|
|
312
|
+
async CreateRecords(records, indexName) {
|
|
313
|
+
try {
|
|
314
|
+
if (!indexName) {
|
|
315
|
+
return this.WrapFailureResponse('Collection name (indexName) is required for CreateRecords');
|
|
316
|
+
}
|
|
317
|
+
const points = records.map((r) => ({
|
|
318
|
+
id: r.id,
|
|
319
|
+
vector: r.values,
|
|
320
|
+
payload: (r.metadata || {}),
|
|
321
|
+
}));
|
|
322
|
+
await this._client.upsert(indexName, { points });
|
|
323
|
+
return this.WrapSuccessResponse(null);
|
|
324
|
+
}
|
|
325
|
+
catch (ex) {
|
|
326
|
+
LogError('Error creating records in Qdrant', undefined, ex);
|
|
327
|
+
return this.WrapFailureResponse('Failed to create records');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Retrieve a single point by ID. Delegates to {@link GetRecords}.
|
|
332
|
+
*
|
|
333
|
+
* @param params - Request parameters. `params.id` is the point ID and
|
|
334
|
+
* `params.data.collectionName` identifies the target collection. Both are required.
|
|
335
|
+
* @returns A {@link BaseResponse} whose `data` is an array of {@link VectorRecord}
|
|
336
|
+
* objects on success, or a failure response on error.
|
|
337
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
338
|
+
*/
|
|
339
|
+
async GetRecord(params) {
|
|
340
|
+
return this.GetRecords(params);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Retrieve multiple points by their IDs from a Qdrant collection.
|
|
344
|
+
*
|
|
345
|
+
* @param params - Request parameters. `params.data.collectionName` is the target
|
|
346
|
+
* collection and `params.data.ids` is the array of point IDs to retrieve.
|
|
347
|
+
* If `ids` is not provided, `params.id` is used as a single-element list.
|
|
348
|
+
* @returns A {@link BaseResponse} whose `data` is an array of {@link VectorRecord}
|
|
349
|
+
* objects on success, or a failure response on error.
|
|
350
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
351
|
+
*/
|
|
352
|
+
async GetRecords(params) {
|
|
353
|
+
try {
|
|
354
|
+
const collectionName = params.data?.collectionName;
|
|
355
|
+
const ids = params.data?.ids || [params.id];
|
|
356
|
+
if (!collectionName) {
|
|
357
|
+
return this.WrapFailureResponse('collectionName is required in params.data');
|
|
358
|
+
}
|
|
359
|
+
const points = await this._client.retrieve(collectionName, {
|
|
360
|
+
ids,
|
|
361
|
+
with_payload: true,
|
|
362
|
+
with_vector: true,
|
|
363
|
+
});
|
|
364
|
+
const records = points.map((p) => ({
|
|
365
|
+
id: String(p.id),
|
|
366
|
+
values: Array.isArray(p.vector) ? p.vector : [],
|
|
367
|
+
metadata: (p.payload || {}),
|
|
368
|
+
}));
|
|
369
|
+
return this.WrapSuccessResponse(records);
|
|
370
|
+
}
|
|
371
|
+
catch (ex) {
|
|
372
|
+
LogError('Error getting records from Qdrant', undefined, ex);
|
|
373
|
+
return this.WrapFailureResponse('Failed to get records');
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Update a single record. Delegates to {@link UpdateRecords}.
|
|
378
|
+
*
|
|
379
|
+
* If the record includes `values`, the point is upserted (vector + payload replaced).
|
|
380
|
+
* If only `metadata` is provided (no `values`), the payload is updated in place
|
|
381
|
+
* via Qdrant's `setPayload` operation without touching the vector.
|
|
382
|
+
*
|
|
383
|
+
* @param record - Update options including `id`, optional `values`, optional `metadata`,
|
|
384
|
+
* and `data.collectionName` (required).
|
|
385
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
386
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
387
|
+
*/
|
|
388
|
+
async UpdateRecord(record) {
|
|
389
|
+
return this.UpdateRecords(record);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Update one or more records in a Qdrant collection.
|
|
393
|
+
*
|
|
394
|
+
* Records with `values` are upserted (full point replacement). Records with only
|
|
395
|
+
* `metadata` (no `values`) are updated via `setPayload` to modify the payload
|
|
396
|
+
* without changing the vector.
|
|
397
|
+
*
|
|
398
|
+
* @param records - Update options. Must include `data.collectionName`. For batch
|
|
399
|
+
* operations, provide `data.records` as an array of individual update options.
|
|
400
|
+
* For single-record updates, the top-level id/values/metadata are used.
|
|
401
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
402
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
403
|
+
*/
|
|
404
|
+
async UpdateRecords(records) {
|
|
405
|
+
try {
|
|
406
|
+
const data = records;
|
|
407
|
+
const collectionName = data.data?.collectionName;
|
|
408
|
+
if (!collectionName) {
|
|
409
|
+
return this.WrapFailureResponse('collectionName is required in records.data for UpdateRecords');
|
|
410
|
+
}
|
|
411
|
+
const recordsList = data.data?.records || [records];
|
|
412
|
+
const points = recordsList
|
|
413
|
+
.filter((r) => r.values) // Only include records with vectors
|
|
414
|
+
.map((r) => ({
|
|
415
|
+
id: r.id,
|
|
416
|
+
vector: r.values,
|
|
417
|
+
payload: (r.metadata || {}),
|
|
418
|
+
}));
|
|
419
|
+
if (points.length > 0) {
|
|
420
|
+
await this._client.upsert(collectionName, { points });
|
|
421
|
+
}
|
|
422
|
+
// For metadata-only updates (no vectors), use setPayload
|
|
423
|
+
const metadataOnlyRecords = recordsList.filter((r) => !r.values && r.metadata);
|
|
424
|
+
for (const r of metadataOnlyRecords) {
|
|
425
|
+
await this._client.setPayload(collectionName, {
|
|
426
|
+
payload: r.metadata,
|
|
427
|
+
points: [r.id],
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
return this.WrapSuccessResponse(null);
|
|
431
|
+
}
|
|
432
|
+
catch (ex) {
|
|
433
|
+
LogError('Error updating records in Qdrant', undefined, ex);
|
|
434
|
+
return this.WrapFailureResponse('Failed to update records');
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Delete a single point from a Qdrant collection.
|
|
439
|
+
* Delegates to {@link DeleteRecords} with a single-element array.
|
|
440
|
+
*
|
|
441
|
+
* @param record - The record to delete; only `record.id` is used.
|
|
442
|
+
* @param indexName - The target collection name. Required.
|
|
443
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
444
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
445
|
+
*/
|
|
446
|
+
async DeleteRecord(record, indexName) {
|
|
447
|
+
return this.DeleteRecords([record], indexName);
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Delete multiple points from a Qdrant collection in a single batch operation.
|
|
451
|
+
*
|
|
452
|
+
* @param records - The records to delete; only their `id` fields are used.
|
|
453
|
+
* @param indexName - The target collection name. Required.
|
|
454
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
455
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
456
|
+
*/
|
|
457
|
+
async DeleteRecords(records, indexName) {
|
|
458
|
+
try {
|
|
459
|
+
if (!indexName) {
|
|
460
|
+
return this.WrapFailureResponse('Collection name (indexName) is required for DeleteRecords');
|
|
461
|
+
}
|
|
462
|
+
const ids = records.map((r) => r.id);
|
|
463
|
+
await this._client.delete(indexName, {
|
|
464
|
+
points: ids,
|
|
465
|
+
});
|
|
466
|
+
return this.WrapSuccessResponse(null);
|
|
467
|
+
}
|
|
468
|
+
catch (ex) {
|
|
469
|
+
LogError('Error deleting records from Qdrant', undefined, ex);
|
|
470
|
+
return this.WrapFailureResponse('Failed to delete records');
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Delete **all** points from a collection by dropping and recreating it with the
|
|
475
|
+
* same vector configuration. Qdrant does not expose a native "truncate" operation.
|
|
476
|
+
*
|
|
477
|
+
* Warning: This resets all optimizer and indexing state for the collection.
|
|
478
|
+
*
|
|
479
|
+
* @param indexName - The target collection name.
|
|
480
|
+
* @param _namespace - Ignored; Qdrant does not use namespaces.
|
|
481
|
+
* @returns A {@link BaseResponse} indicating success or failure.
|
|
482
|
+
* @throws Never throws; errors are caught and returned as a failure response.
|
|
483
|
+
*/
|
|
484
|
+
async DeleteAllRecords(indexName, _namespace) {
|
|
485
|
+
try {
|
|
486
|
+
// Get collection info to preserve config
|
|
487
|
+
const info = await this._client.getCollection(indexName);
|
|
488
|
+
const vectorsConfig = info.config?.params?.vectors;
|
|
489
|
+
// Delete the collection
|
|
490
|
+
await this._client.deleteCollection(indexName);
|
|
491
|
+
// Recreate with the same vector configuration
|
|
492
|
+
if (vectorsConfig && typeof vectorsConfig === 'object') {
|
|
493
|
+
await this._client.createCollection(indexName, {
|
|
494
|
+
vectors: vectorsConfig,
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
return this.WrapSuccessResponse(null);
|
|
498
|
+
}
|
|
499
|
+
catch (ex) {
|
|
500
|
+
LogError('Error deleting all records from Qdrant', undefined, ex);
|
|
501
|
+
return this.WrapFailureResponse('Failed to delete all records');
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* List vector IDs using Qdrant's scroll API with optional metadata filtering
|
|
506
|
+
* and cursor-based pagination.
|
|
507
|
+
*
|
|
508
|
+
* @param params - Parameters including `IndexName` (collection name), optional `Limit`
|
|
509
|
+
* (default 100), optional `PaginationToken` (Qdrant scroll offset from a
|
|
510
|
+
* previous call), and optional `MetadataFilter` (key-value pairs translated
|
|
511
|
+
* to Qdrant `must` match conditions).
|
|
512
|
+
* @returns A {@link ListVectorIDsResult} with the matching IDs and an optional
|
|
513
|
+
* `NextPaginationToken` for the next page.
|
|
514
|
+
* @throws Never throws; errors are caught and an empty result is returned.
|
|
515
|
+
*/
|
|
516
|
+
async ListVectorIDs(params) {
|
|
517
|
+
try {
|
|
518
|
+
const limit = params.Limit ?? 100;
|
|
519
|
+
// Build Qdrant filter from metadata filter
|
|
520
|
+
let filter;
|
|
521
|
+
if (params.MetadataFilter) {
|
|
522
|
+
const must = [];
|
|
523
|
+
for (const [key, value] of Object.entries(params.MetadataFilter)) {
|
|
524
|
+
must.push({
|
|
525
|
+
key,
|
|
526
|
+
match: { value },
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
filter = { must };
|
|
530
|
+
}
|
|
531
|
+
const scrollParams = {
|
|
532
|
+
limit,
|
|
533
|
+
with_payload: false,
|
|
534
|
+
with_vector: false,
|
|
535
|
+
};
|
|
536
|
+
if (filter) {
|
|
537
|
+
scrollParams['filter'] = filter;
|
|
538
|
+
}
|
|
539
|
+
if (params.PaginationToken) {
|
|
540
|
+
scrollParams['offset'] = params.PaginationToken;
|
|
541
|
+
}
|
|
542
|
+
const result = await this._client.scroll(params.IndexName, scrollParams);
|
|
543
|
+
const ids = result.points.map((p) => String(p.id));
|
|
544
|
+
const nextOffset = result.next_page_offset;
|
|
545
|
+
return {
|
|
546
|
+
IDs: ids,
|
|
547
|
+
NextPaginationToken: nextOffset != null ? String(nextOffset) : undefined,
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
catch (ex) {
|
|
551
|
+
LogError('Error listing vector IDs from Qdrant', undefined, ex);
|
|
552
|
+
return { IDs: [] };
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Build a Qdrant-native filter from the shared {@link SharedIndexFilterOptions}
|
|
557
|
+
* interface used across all MJ vector providers.
|
|
558
|
+
*
|
|
559
|
+
* The shared filter options (EntityName, RecordIDs, etc.) are first converted to
|
|
560
|
+
* generic {@link MetadataFilterCondition} objects via `VectorMetadataFilter.BuildConditions`,
|
|
561
|
+
* then translated into Qdrant's structured filter format. The resulting filter uses
|
|
562
|
+
* `must` clauses with `match.value` for equality and `match.any` for set membership.
|
|
563
|
+
*
|
|
564
|
+
* @param options - The provider-agnostic filter options.
|
|
565
|
+
* @returns A Qdrant filter object suitable for passing as `QueryOptions.filter`,
|
|
566
|
+
* or `undefined` if the options produce no conditions.
|
|
567
|
+
*/
|
|
568
|
+
BuildMetadataFilter(options) {
|
|
569
|
+
const conditions = VectorMetadataFilter.BuildConditions(options);
|
|
570
|
+
if (conditions.length === 0) {
|
|
571
|
+
return undefined;
|
|
572
|
+
}
|
|
573
|
+
return this.ConditionsToQdrantFilter(conditions);
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Convert MetadataFilterConditions to Qdrant's native filter syntax.
|
|
577
|
+
*/
|
|
578
|
+
ConditionsToQdrantFilter(conditions) {
|
|
579
|
+
const must = [];
|
|
580
|
+
for (const condition of conditions) {
|
|
581
|
+
switch (condition.Operator) {
|
|
582
|
+
case 'eq':
|
|
583
|
+
must.push({
|
|
584
|
+
key: condition.Field,
|
|
585
|
+
match: { value: condition.Value },
|
|
586
|
+
});
|
|
587
|
+
break;
|
|
588
|
+
case 'in':
|
|
589
|
+
if (Array.isArray(condition.Value)) {
|
|
590
|
+
must.push({
|
|
591
|
+
key: condition.Field,
|
|
592
|
+
match: { any: condition.Value },
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
must.push({
|
|
597
|
+
key: condition.Field,
|
|
598
|
+
match: { value: condition.Value },
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
break;
|
|
602
|
+
case 'contains':
|
|
603
|
+
must.push({
|
|
604
|
+
key: condition.Field,
|
|
605
|
+
match: { value: condition.Value },
|
|
606
|
+
});
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return { must };
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Extract collection name from query params. Checks for 'id' field first (used as collection name
|
|
614
|
+
* when vector is also provided), otherwise returns undefined.
|
|
615
|
+
*/
|
|
616
|
+
ExtractCollectionName(params) {
|
|
617
|
+
if ('id' in params && typeof params.id === 'string') {
|
|
618
|
+
// When both vector and id are present, id is the collection name
|
|
619
|
+
if ('vector' in params && params.vector) {
|
|
620
|
+
return params.id;
|
|
621
|
+
}
|
|
622
|
+
// When only id, it's used as point ID; need collectionName from somewhere else
|
|
623
|
+
// Fall through - caller should provide collection name
|
|
624
|
+
}
|
|
625
|
+
// Check if filter has a collectionName hint
|
|
626
|
+
const filter = params.filter;
|
|
627
|
+
if (filter && typeof filter['collectionName'] === 'string') {
|
|
628
|
+
return filter['collectionName'];
|
|
629
|
+
}
|
|
630
|
+
return undefined;
|
|
631
|
+
}
|
|
632
|
+
WrapSuccessResponse(data) {
|
|
633
|
+
return {
|
|
634
|
+
success: true,
|
|
635
|
+
message: '',
|
|
636
|
+
data: data,
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
WrapFailureResponse(message) {
|
|
640
|
+
return {
|
|
641
|
+
success: false,
|
|
642
|
+
message: message || 'An error occurred',
|
|
643
|
+
data: null,
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
QdrantDatabase = __decorate([
|
|
648
|
+
RegisterClass(VectorDBBase, 'QdrantDatabase'),
|
|
649
|
+
__metadata("design:paramtypes", [String])
|
|
650
|
+
], QdrantDatabase);
|
|
651
|
+
export { QdrantDatabase };
|
|
652
|
+
//# sourceMappingURL=QdrantDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QdrantDatabase.js","sourceRoot":"","sources":["../../src/models/QdrantDatabase.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAWH,YAAY,EACZ,oBAAoB,GAKvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAa,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;GAEG;AACH,SAAS,wBAAwB,CAAC,MAA4B;IAC1D,QAAQ,MAAM,EAAE,CAAC;QACb,KAAK,QAAQ;YACT,OAAO,QAAQ,CAAC;QACpB,KAAK,WAAW;YACZ,OAAO,QAAQ,CAAC;QACpB,KAAK,YAAY;YACb,OAAO,KAAK,CAAC;QACjB;YACI,OAAO,QAAQ,CAAC;IACxB,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB,CAAC,QAAgB;IAC9C,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,QAAQ;YACT,OAAO,QAAQ,CAAC;QACpB,KAAK,QAAQ;YACT,OAAO,WAAW,CAAC;QACvB,KAAK,KAAK;YACN,OAAO,YAAY,CAAC;QACxB;YACI,OAAO,QAAQ,CAAC;IACxB,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,YAAY;IAG5C,YAAY,MAAc;QACtB,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC;YAC5B,GAAG,EAAE,SAAS;YACd,MAAM,EAAE,MAAM,IAAI,SAAS;SA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IACN,CAAC;IAEO,mBAAmB,CAAC,OAAgB;QACxC,OAAO;YACH,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,OAAO,IAAI,mBAAmB;YACvC,IAAI,EAAE,IAAI;SACb,CAAC;IACN,CAAC;CACJ,CAAA;AAjnBY,cAAc;IAD1B,aAAa,CAAC,YAAY,EAAE,gBAAgB,CAAC;;GACjC,cAAc,CAinB1B"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ai-vectors-qdrant",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "5.24.0",
|
|
5
|
+
"description": "MemberJunction: Qdrant Implementation for AI Vector Database",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "ts-node-dev src/index.ts",
|
|
13
|
+
"build": "tsc && tsc-alias -f",
|
|
14
|
+
"test": "vitest run"
|
|
15
|
+
},
|
|
16
|
+
"author": "MemberJunction.com",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@memberjunction/core": "5.24.0",
|
|
20
|
+
"@memberjunction/global": "5.24.0",
|
|
21
|
+
"@memberjunction/ai-vectordb": "5.24.0",
|
|
22
|
+
"@qdrant/js-client-rest": "^1.13.0",
|
|
23
|
+
"dotenv": "^17.2.4"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "24.10.11",
|
|
27
|
+
"ts-node-dev": "^2.0.0",
|
|
28
|
+
"typescript": "^5.9.3"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/MemberJunction/MJ"
|
|
33
|
+
}
|
|
10
34
|
}
|