@memberjunction/ai-vectordb 5.20.0 → 5.22.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @memberjunction/ai-vectordb
2
2
 
3
- A provider-agnostic abstraction layer for vector databases in MemberJunction. This package defines the abstract base class, type system, and query interfaces that concrete vector database implementations (such as Pinecone) must fulfill.
3
+ A provider-agnostic abstraction layer for vector databases in MemberJunction. This package defines the `VectorDBBase` abstract class and all associated types that concrete vector database implementations must fulfill. It contains no provider-specific logic -- only the contracts, data structures, and query interfaces shared across all implementations.
4
4
 
5
5
  ## Architecture
6
6
 
@@ -9,7 +9,7 @@ graph TD
9
9
  subgraph Abstraction["@memberjunction/ai-vectordb"]
10
10
  VDBB["VectorDBBase (abstract)"]
11
11
  VR["VectorRecord"]
12
- QO["QueryOptions"]
12
+ QO["QueryOptions / HybridQueryOptions"]
13
13
  QR["QueryResponse / ScoredRecord"]
14
14
  IDX["IndexDescription / IndexList"]
15
15
  BR["BaseResponse"]
@@ -37,29 +37,47 @@ graph TD
37
37
  style Consumers fill:#7c5295,stroke:#563a6b,color:#fff
38
38
  ```
39
39
 
40
+ All vector database providers extend `VectorDBBase` and implement its abstract methods. Consumer code programs against the base class, making it straightforward to swap providers without changing application logic.
41
+
40
42
  ## Installation
41
43
 
42
44
  ```bash
43
45
  npm install @memberjunction/ai-vectordb
44
46
  ```
45
47
 
46
- ## Overview
47
-
48
- This package provides:
48
+ ## Quick Start
49
49
 
50
- - **VectorDBBase** -- an abstract class that defines a complete API for vector database operations (index management + record CRUD + similarity queries)
51
- - **Record types** -- `VectorRecord`, `RecordValues`, `RecordSparseValues`, `RecordMetadata` for representing vectors and their metadata
52
- - **Query types** -- `QueryOptions`, `QueryResponse`, `ScoredRecord` for similarity search
53
- - **Index types** -- `IndexDescription`, `IndexList`, `IndexModelMetricEnum` for index configuration
54
- - **Response types** -- `BaseResponse` for standardized success/failure responses
50
+ ```typescript
51
+ import { VectorDBBase, VectorRecord } from '@memberjunction/ai-vectordb';
55
52
 
56
- Concrete implementations like `@memberjunction/ai-vectors-pinecone` extend `VectorDBBase` to connect to specific vector database services.
53
+ // Use any concrete provider that extends VectorDBBase
54
+ const db: VectorDBBase = new PineconeDatabase(apiKey);
57
55
 
58
- ## Core Components
56
+ // Insert a vector record
57
+ const record: VectorRecord = {
58
+ id: 'doc-001',
59
+ values: [0.1, 0.2, 0.3 /* ... */],
60
+ metadata: { entity: 'Products', recordId: '12345' }
61
+ };
62
+ await db.createRecord(record);
63
+
64
+ // Query for similar vectors
65
+ const result = await db.queryIndex({
66
+ vector: [0.1, 0.2, 0.3 /* ... */],
67
+ topK: 10,
68
+ includeMetadata: true
69
+ });
70
+
71
+ if (result.success) {
72
+ for (const match of result.data.matches) {
73
+ console.log(`Match: ${match.id} (score: ${match.score})`);
74
+ }
75
+ }
76
+ ```
59
77
 
60
- ### VectorDBBase (Abstract Class)
78
+ ## VectorDBBase Abstract Class
61
79
 
62
- All vector database providers must extend this class. The constructor requires an API key, which is validated and stored for subclass access via a protected getter.
80
+ All vector database providers must extend this class. The constructor requires an API key, which is validated (must be non-empty) and stored for subclass access via a protected getter.
63
81
 
64
82
  ```mermaid
65
83
  classDiagram
@@ -67,12 +85,14 @@ classDiagram
67
85
  <<abstract>>
68
86
  #apiKey : string
69
87
  +constructor(apiKey: string)
88
+ +SupportsHybridSearch : boolean
70
89
  +listIndexes()* IndexList
71
90
  +getIndex(params)* BaseResponse
72
91
  +createIndex(params)* BaseResponse
73
92
  +deleteIndex(params)* BaseResponse
74
93
  +editIndex(params)* BaseResponse
75
94
  +queryIndex(params)* BaseResponse
95
+ +HybridQuery(params) BaseResponse
76
96
  +createRecord(record)* BaseResponse
77
97
  +createRecords(records)* BaseResponse
78
98
  +getRecord(params)* BaseResponse
@@ -88,213 +108,415 @@ classDiagram
88
108
  +queryIndex(params) BaseResponse
89
109
  }
90
110
 
111
+ class CustomProvider {
112
+ +SupportsHybridSearch : boolean
113
+ +HybridQuery(params) BaseResponse
114
+ }
115
+
91
116
  VectorDBBase <|-- PineconeDatabase
117
+ VectorDBBase <|-- CustomProvider
92
118
 
93
119
  style VectorDBBase fill:#2d6a9f,stroke:#1a4971,color:#fff
94
120
  style PineconeDatabase fill:#2d8659,stroke:#1a5c3a,color:#fff
121
+ style CustomProvider fill:#2d8659,stroke:#1a5c3a,color:#fff
95
122
  ```
96
123
 
97
- The abstract methods support both synchronous and asynchronous return types via union types (`BaseResponse | Promise<BaseResponse>`), allowing implementations to choose the appropriate pattern.
124
+ All abstract methods use union return types (`BaseResponse | Promise<BaseResponse>`) so subclasses can implement them as either synchronous or asynchronous.
98
125
 
99
- ### Type System
126
+ ## Abstract Methods Reference
100
127
 
101
- #### Vector Records
102
-
103
- ```typescript
104
- // Core vector record with generic metadata support
105
- type VectorRecord<T extends RecordMetadata = RecordMetadata> = {
106
- id: string; // Unique record identifier
107
- values: RecordValues; // Dense vector (array of numbers)
108
- sparseValues?: RecordSparseValues; // Optional sparse representation for hybrid search
109
- metadata?: T; // Arbitrary filterable metadata
110
- };
128
+ ### Index Operations
111
129
 
112
- type RecordValues = Array<number>;
130
+ | Method | Parameters | Returns | Description |
131
+ |---|---|---|---|
132
+ | `listIndexes()` | none | `IndexList` | List all indexes in the project. |
133
+ | `getIndex(params)` | `BaseRequestParams` | `BaseResponse` | Retrieve configuration details for a single index by ID. |
134
+ | `createIndex(params)` | `CreateIndexParams` | `BaseResponse` | Create a new vector index with specified dimension, metric, and optional provider-specific params. |
135
+ | `deleteIndex(params)` | `BaseRequestParams` | `BaseResponse` | Permanently delete an index and all its records. |
136
+ | `editIndex(params)` | `EditIndexParams` | `BaseResponse` | Modify an existing index's configuration. |
137
+ | `queryIndex(params)` | `QueryOptions` | `BaseResponse` | Execute a similarity search against an index by vector values or by record ID. |
113
138
 
114
- type RecordSparseValues = {
115
- indices: Array<number>; // Non-zero positions
116
- values: Array<number>; // Corresponding values
117
- };
139
+ ### Record Operations
118
140
 
119
- type RecordMetadataValue = string | boolean | number | Array<string>;
120
- type RecordMetadata = Record<string, RecordMetadataValue>;
121
- ```
141
+ | Method | Parameters | Returns | Description |
142
+ |---|---|---|---|
143
+ | `createRecord(record)` | `VectorRecord` | `BaseResponse` | Insert a single vector record into an index. |
144
+ | `createRecords(records)` | `VectorRecord[]` | `BaseResponse` | Insert multiple vector records in batch. |
145
+ | `getRecord(params)` | `BaseRequestParams` | `BaseResponse` | Fetch a single record by ID. |
146
+ | `getRecords(params)` | `BaseRequestParams` | `BaseResponse` | Fetch multiple records (IDs passed via `data`). |
147
+ | `updateRecord(record)` | `UpdateOptions` | `BaseResponse` | Update a single record's vector values and/or metadata. |
148
+ | `updateRecords(records)` | `UpdateOptions` | `BaseResponse` | Update multiple records in batch. |
149
+ | `deleteRecord(record)` | `VectorRecord` | `BaseResponse` | Delete a single record from an index. |
150
+ | `deleteRecords(records)` | `VectorRecord[]` | `BaseResponse` | Delete multiple records in batch. |
122
151
 
123
- #### Index Configuration
152
+ ### Virtual Methods (Non-Abstract)
124
153
 
125
- ```typescript
126
- type IndexDescription = {
127
- name: string; // Index name (max 45 chars)
128
- dimension: number; // Vector dimensionality
129
- metric: IndexModelMetricEnum; // 'cosine' | 'euclidean' | 'dotproduct'
130
- host: string; // Hosting URL
131
- };
132
- ```
154
+ | Method | Parameters | Returns | Description |
155
+ |---|---|---|---|
156
+ | `SupportsHybridSearch` (getter) | none | `boolean` | Returns `false` by default. Override to return `true` in providers that implement `HybridQuery()`. |
157
+ | `HybridQuery(params)` | `HybridQueryOptions` | `BaseResponse` | Perform a hybrid search combining vector similarity with keyword matching. Default implementation falls back to `queryIndex()`. |
133
158
 
134
- #### Query Types
159
+ ## Hybrid Search
135
160
 
136
- ```mermaid
137
- graph LR
138
- QPB["QueryParamsBase<br/>topK, includeValues,<br/>includeMetadata, filter"]
139
- QBV["QueryByVectorValues<br/>+ vector"]
140
- QBID["QueryByRecordId<br/>+ id"]
141
- QO["QueryOptions"]
161
+ Hybrid search combines dense vector similarity (semantic search) with sparse keyword matching (BM25) to produce more relevant results than either technique alone. This is particularly useful when queries contain specific terms (product names, codes, identifiers) that benefit from exact text matching alongside semantic understanding.
142
162
 
143
- QPB --> QBV
144
- QPB --> QBID
145
- QBV --> QO
146
- QBID --> QO
163
+ ### How It Works
147
164
 
148
- style QPB fill:#2d6a9f,stroke:#1a4971,color:#fff
149
- style QBV fill:#2d8659,stroke:#1a5c3a,color:#fff
150
- style QBID fill:#2d8659,stroke:#1a5c3a,color:#fff
151
- style QO fill:#b8762f,stroke:#8a5722,color:#fff
152
- ```
165
+ 1. **Check support**: Read the `SupportsHybridSearch` getter before calling `HybridQuery()`.
166
+ 2. **Call HybridQuery**: Pass both a vector embedding and an optional keyword query string.
167
+ 3. **Fallback behavior**: If the provider does not override `HybridQuery()`, the base class automatically falls back to a pure vector `queryIndex()` call, ignoring keyword-specific parameters (`KeywordQuery`, `Alpha`, `FusionMethod`). This means consumer code does not need to branch on provider capability -- it is always safe to call `HybridQuery()`.
153
168
 
154
- ```typescript
155
- // Base query parameters shared by all query types
156
- type QueryParamsBase = {
157
- topK: number; // Number of results to return
158
- includeValues?: boolean; // Include vector values in results
159
- includeMetadata?: boolean; // Include metadata in results
160
- filter?: object; // Metadata filter
161
- };
169
+ ### HybridQueryOptions
162
170
 
163
- // Query by providing a vector directly
164
- type QueryByVectorValues = QueryParamsBase & { vector: RecordValues };
171
+ `HybridQueryOptions` extends `QueryParamsBase` with the following additional fields:
165
172
 
166
- // Query using an existing record's vector
167
- type QueryByRecordId = QueryParamsBase & { id: string };
173
+ | Property | Type | Required | Description |
174
+ |---|---|---|---|
175
+ | `vector` | `RecordValues` | Yes | Embedding vector for the semantic similarity component. |
176
+ | `KeywordQuery` | `string` | No | Keyword query string for BM25/text search. |
177
+ | `Alpha` | `number` | No | Balance between vector and keyword results. `0.0` = pure keyword, `1.0` = pure vector. Default: `0.7`. |
178
+ | `FusionMethod` | `'rrf' \| 'weighted'` | No | Strategy for fusing vector and keyword result lists. Default: `'rrf'` (Reciprocal Rank Fusion). |
168
179
 
169
- // Union type for all query configurations
170
- type QueryOptions = QueryByRecordId | QueryByVectorValues;
171
- ```
180
+ Plus the inherited `QueryParamsBase` fields: `topK`, `includeValues`, `includeMetadata`, `filter`.
172
181
 
173
- #### Query Response
182
+ ### Implementing Hybrid Search in a Provider
174
183
 
175
184
  ```typescript
176
- type QueryResponse<T extends RecordMetadata = RecordMetadata> = {
177
- matches: Array<ScoredRecord<T>>; // Sorted by similarity
178
- namespace: string; // Execution namespace
179
- usage?: OperationUsage; // Read unit consumption
180
- };
185
+ import { VectorDBBase, HybridQueryOptions, BaseResponse } from '@memberjunction/ai-vectordb';
186
+
187
+ export class WeaviateDB extends VectorDBBase {
188
+ public override get SupportsHybridSearch(): boolean {
189
+ return true;
190
+ }
191
+
192
+ public override async HybridQuery(params: HybridQueryOptions): Promise<BaseResponse> {
193
+ const results = await this.client.hybridSearch({
194
+ vector: params.vector,
195
+ query: params.KeywordQuery,
196
+ alpha: params.Alpha ?? 0.7,
197
+ fusionType: params.FusionMethod ?? 'rrf',
198
+ limit: params.topK,
199
+ includeMetadata: params.includeMetadata
200
+ });
201
+ return { success: true, message: 'Hybrid query complete', data: results };
202
+ }
181
203
 
182
- interface ScoredRecord<T> extends VectorRecord<T> {
183
- score?: number; // Similarity score (interpretation depends on metric)
204
+ // ... remaining abstract method implementations
184
205
  }
185
206
  ```
186
207
 
187
- #### Standardized Response
188
-
189
- All operations return a `BaseResponse`:
208
+ ### Consumer Usage
190
209
 
191
210
  ```typescript
192
- type BaseResponse = {
193
- success: boolean;
194
- message: string;
195
- data: unknown;
196
- };
211
+ const db: VectorDBBase = getVectorProvider();
212
+
213
+ // Safe to call regardless of provider -- falls back to pure vector search
214
+ const results = await db.HybridQuery({
215
+ vector: embedding,
216
+ KeywordQuery: 'quarterly revenue report',
217
+ Alpha: 0.6,
218
+ topK: 20,
219
+ includeMetadata: true
220
+ });
221
+
222
+ // Or check support for conditional UI behavior
223
+ if (db.SupportsHybridSearch) {
224
+ showKeywordSearchInput();
225
+ }
197
226
  ```
198
227
 
199
- ## Usage
228
+ ## Implementing a Custom Provider
200
229
 
201
- ### Implementing a Provider
230
+ Follow these steps to add support for a new vector database (e.g., Weaviate, Qdrant, Milvus).
231
+
232
+ ### Step 1: Create the Provider Class
202
233
 
203
234
  ```typescript
204
235
  import {
205
236
  VectorDBBase,
206
- VectorRecord,
237
+ BaseRequestParams,
207
238
  BaseResponse,
208
239
  CreateIndexParams,
240
+ EditIndexParams,
241
+ IndexList,
209
242
  QueryOptions,
210
- IndexList
243
+ UpdateOptions,
244
+ VectorRecord
211
245
  } from '@memberjunction/ai-vectordb';
212
246
 
213
- export class MyVectorDB extends VectorDBBase {
214
- constructor(apiKey: string) {
215
- super(apiKey); // Validates and stores the API key
247
+ export class QdrantDB extends VectorDBBase {
248
+ private client: QdrantClient;
249
+
250
+ constructor(apiKey: string, host: string) {
251
+ super(apiKey); // Validates the API key
252
+ this.client = new QdrantClient({ apiKey: this.apiKey, host });
216
253
  }
217
254
 
218
255
  async listIndexes(): Promise<IndexList> {
219
- // Call your vector DB API using this.apiKey
220
- return { indexes: [] };
256
+ const collections = await this.client.getCollections();
257
+ return {
258
+ indexes: collections.map(c => ({
259
+ name: c.name,
260
+ dimension: c.vectors.size,
261
+ metric: c.vectors.distance,
262
+ host: this.host
263
+ }))
264
+ };
265
+ }
266
+
267
+ async getIndex(params: BaseRequestParams): Promise<BaseResponse> {
268
+ const info = await this.client.getCollection(params.id);
269
+ return { success: true, message: 'Index retrieved', data: info };
221
270
  }
222
271
 
223
272
  async createIndex(params: CreateIndexParams): Promise<BaseResponse> {
224
- return { success: true, message: 'Created', data: { id: params.id } };
273
+ await this.client.createCollection(params.id, {
274
+ vectors: { size: params.dimension, distance: params.metric }
275
+ });
276
+ return { success: true, message: 'Index created', data: null };
277
+ }
278
+
279
+ async deleteIndex(params: BaseRequestParams): Promise<BaseResponse> {
280
+ await this.client.deleteCollection(params.id);
281
+ return { success: true, message: 'Index deleted', data: null };
282
+ }
283
+
284
+ async editIndex(params: EditIndexParams): Promise<BaseResponse> {
285
+ await this.client.updateCollection(params.id, params.data);
286
+ return { success: true, message: 'Index updated', data: null };
225
287
  }
226
288
 
227
289
  async queryIndex(params: QueryOptions): Promise<BaseResponse> {
228
- // Perform similarity search
229
- return { success: true, message: 'OK', data: { matches: [] } };
290
+ const results = await this.client.search(params);
291
+ return { success: true, message: 'Query complete', data: results };
292
+ }
293
+
294
+ async createRecord(record: VectorRecord): Promise<BaseResponse> {
295
+ await this.client.upsert([record]);
296
+ return { success: true, message: 'Record created', data: null };
297
+ }
298
+
299
+ async createRecords(records: VectorRecord[]): Promise<BaseResponse> {
300
+ await this.client.upsert(records);
301
+ return { success: true, message: `${records.length} records created`, data: null };
302
+ }
303
+
304
+ async getRecord(params: BaseRequestParams): Promise<BaseResponse> {
305
+ const record = await this.client.retrieve(params.id);
306
+ return { success: true, message: 'Record retrieved', data: record };
307
+ }
308
+
309
+ async getRecords(params: BaseRequestParams): Promise<BaseResponse> {
310
+ const records = await this.client.retrieveMany(params.data);
311
+ return { success: true, message: 'Records retrieved', data: records };
312
+ }
313
+
314
+ async updateRecord(record: UpdateOptions): Promise<BaseResponse> {
315
+ await this.client.update(record);
316
+ return { success: true, message: 'Record updated', data: null };
317
+ }
318
+
319
+ async updateRecords(records: UpdateOptions): Promise<BaseResponse> {
320
+ await this.client.updateMany(records);
321
+ return { success: true, message: 'Records updated', data: null };
230
322
  }
231
323
 
232
- // ... implement remaining abstract methods
324
+ async deleteRecord(record: VectorRecord): Promise<BaseResponse> {
325
+ await this.client.delete(record.id);
326
+ return { success: true, message: 'Record deleted', data: null };
327
+ }
328
+
329
+ async deleteRecords(records: VectorRecord[]): Promise<BaseResponse> {
330
+ await this.client.deleteMany(records.map(r => r.id));
331
+ return { success: true, message: 'Records deleted', data: null };
332
+ }
233
333
  }
234
334
  ```
235
335
 
236
- ### Consuming a Provider
336
+ ### Step 2: Register with MemberJunction Class Factory (Optional)
337
+
338
+ If you want MemberJunction's class factory to discover your provider automatically:
237
339
 
238
340
  ```typescript
239
- import { VectorDBBase, VectorRecord } from '@memberjunction/ai-vectordb';
341
+ import { RegisterClass } from '@memberjunction/global';
342
+
343
+ @RegisterClass(VectorDBBase, 'QdrantDB')
344
+ export class QdrantDB extends VectorDBBase {
345
+ // ... implementation
346
+ }
347
+ ```
240
348
 
241
- async function searchSimilar(vectorDB: VectorDBBase, embedding: number[]): Promise<void> {
242
- // Insert a record
243
- const record: VectorRecord = {
244
- id: 'doc-001',
245
- values: embedding,
246
- metadata: { entity: 'Products', recordId: '12345' }
247
- };
248
- await vectorDB.createRecord(record);
249
-
250
- // Query for similar vectors
251
- const result = await vectorDB.queryIndex({
252
- vector: embedding,
253
- topK: 10,
254
- includeMetadata: true
255
- });
256
-
257
- if (result.success) {
258
- for (const match of result.data.matches) {
259
- console.log(`Match: ${match.id} (score: ${match.score})`);
260
- }
349
+ ### Step 3: Add Hybrid Search Support (Optional)
350
+
351
+ If your vector database supports hybrid search natively, override the getter and method:
352
+
353
+ ```typescript
354
+ export class QdrantDB extends VectorDBBase {
355
+ public override get SupportsHybridSearch(): boolean {
356
+ return true;
357
+ }
358
+
359
+ public override async HybridQuery(params: HybridQueryOptions): Promise<BaseResponse> {
360
+ // Use your provider's native hybrid search API
361
+ const results = await this.client.hybridSearch({
362
+ vector: params.vector,
363
+ keyword: params.KeywordQuery,
364
+ alpha: params.Alpha ?? 0.7,
365
+ limit: params.topK
366
+ });
367
+ return { success: true, message: 'Hybrid query complete', data: results };
261
368
  }
262
369
  }
263
370
  ```
264
371
 
372
+ ## QueryOptions Reference
373
+
374
+ `QueryOptions` is a union type supporting two query strategies:
375
+
376
+ ```mermaid
377
+ graph LR
378
+ QPB["QueryParamsBase<br/>topK, includeValues,<br/>includeMetadata, filter"]
379
+ QBV["QueryByVectorValues<br/>+ vector"]
380
+ QBID["QueryByRecordId<br/>+ id"]
381
+ QO["QueryOptions"]
382
+
383
+ QPB --> QBV
384
+ QPB --> QBID
385
+ QBV --> QO
386
+ QBID --> QO
387
+
388
+ style QPB fill:#2d6a9f,stroke:#1a4971,color:#fff
389
+ style QBV fill:#2d8659,stroke:#1a5c3a,color:#fff
390
+ style QBID fill:#2d8659,stroke:#1a5c3a,color:#fff
391
+ style QO fill:#b8762f,stroke:#8a5722,color:#fff
392
+ ```
393
+
394
+ ### QueryParamsBase
395
+
396
+ Shared query parameters inherited by both query strategies.
397
+
398
+ | Property | Type | Required | Description |
399
+ |---|---|---|---|
400
+ | `topK` | `number` | Yes | Number of results to return. |
401
+ | `includeValues` | `boolean` | No | Whether to include embedding vectors in results. Default: `false`. |
402
+ | `includeMetadata` | `boolean` | No | Whether to include metadata in results. Default: `false`. |
403
+ | `filter` | `object` | No | Metadata filter to narrow the search scope. |
404
+
405
+ ### QueryByVectorValues
406
+
407
+ Query by providing a vector directly. Extends `QueryParamsBase`.
408
+
409
+ | Property | Type | Required | Description |
410
+ |---|---|---|---|
411
+ | `vector` | `RecordValues` | Yes | Vector values output from an embedding model. |
412
+
413
+ ### QueryByRecordId
414
+
415
+ Query using an existing record's stored vector. Extends `QueryParamsBase`.
416
+
417
+ | Property | Type | Required | Description |
418
+ |---|---|---|---|
419
+ | `id` | `string` | Yes | ID of an existing record whose vector to use for the query. |
420
+
421
+ ### Usage Examples
422
+
423
+ ```typescript
424
+ // Query by vector values
425
+ const resultByVector = await db.queryIndex({
426
+ vector: [0.1, 0.2, 0.3],
427
+ topK: 5,
428
+ includeMetadata: true,
429
+ filter: { category: 'finance' }
430
+ });
431
+
432
+ // Query by record ID (find similar to an existing record)
433
+ const resultById = await db.queryIndex({
434
+ id: 'doc-001',
435
+ topK: 10,
436
+ includeMetadata: true
437
+ });
438
+ ```
439
+
440
+ ## Type Reference
441
+
442
+ ### Core Types
443
+
444
+ | Type | Description |
445
+ |---|---|
446
+ | `VectorRecord<T>` | A vector record with `id`, `values` (dense embedding), optional `sparseValues`, and optional `metadata`. Generic over metadata type. |
447
+ | `RecordValues` | `Array<number>` -- a dense embedding vector. |
448
+ | `RecordSparseValues` | Sparse vector representation with parallel `indices` and `values` arrays for non-zero positions. |
449
+ | `RecordMetadata` | `Record<string, RecordMetadataValue>` -- arbitrary key-value metadata attached to records. |
450
+ | `RecordMetadataValue` | `string \| boolean \| number \| Array<string>` -- valid metadata value types. |
451
+ | `BaseResponse` | Standard response envelope: `success` (boolean), `message` (string), `data` (result payload). |
452
+
453
+ ### Index Types
454
+
455
+ | Type | Description |
456
+ |---|---|
457
+ | `IndexDescription` | Describes an index: `name` (max 45 chars), `dimension`, `metric`, and `host` URL. |
458
+ | `IndexList` | Container with an optional `indexes` array of `IndexDescription`. |
459
+ | `IndexModelMetricEnum` | `'cosine' \| 'euclidean' \| 'dotproduct'` distance metrics for similarity comparison. |
460
+
461
+ ### Request/Options Types
462
+
463
+ | Type | Description |
464
+ |---|---|
465
+ | `BaseRequestParams` | Base request with `id` (string) and optional `data`. |
466
+ | `CreateIndexParams` | Extends `BaseRequestParams` with `dimension` (number), `metric` (IndexModelMetricEnum), and optional `additionalParams`. |
467
+ | `EditIndexParams` | Extends `BaseRequestParams` for index configuration changes. |
468
+ | `UpdateOptions<T>` | Record update with `id`, optional `values`, optional `sparseValues`, and optional `metadata`. Values are optional to support metadata-only updates. |
469
+
470
+ ### Query Types
471
+
472
+ | Type | Description |
473
+ |---|---|
474
+ | `QueryParamsBase` | Shared query parameters: `topK`, `includeValues`, `includeMetadata`, `filter`. |
475
+ | `QueryByRecordId` | Extends `QueryParamsBase` with `id` -- query using an existing record's vector. |
476
+ | `QueryByVectorValues` | Extends `QueryParamsBase` with `vector` -- query using a raw embedding array. |
477
+ | `QueryOptions` | Union of `QueryByRecordId \| QueryByVectorValues`. |
478
+ | `HybridQueryOptions` | Extends `QueryParamsBase` with `vector`, `KeywordQuery`, `Alpha`, and `FusionMethod` for combined vector + keyword search. |
479
+ | `QueryResponse<T>` | Query result containing `matches` (sorted `ScoredRecord` array), `namespace`, and optional `usage`. |
480
+ | `ScoredRecord<T>` | Extends `VectorRecord` with a `score` field. Score interpretation depends on the index metric. |
481
+ | `OperationUsage` | Usage metrics with optional `readUnits` count. |
482
+
265
483
  ## Distance Metrics
266
484
 
267
485
  The `IndexModelMetricEnum` supports three metrics for similarity comparison:
268
486
 
269
- | Metric | Description | Use Case |
270
- |---|---|---|
271
- | `cosine` | Measures angle between vectors (direction similarity) | Text embeddings, semantic search |
272
- | `euclidean` | Straight-line distance between points | Numeric features, specifications |
273
- | `dotproduct` | Measures both direction and magnitude alignment | Recommendation systems, weighted scoring |
487
+ | Metric | Value | Description | Score Interpretation |
488
+ |---|---|---|---|
489
+ | Cosine | `'cosine'` | Measures angle between vectors (direction similarity) | Higher = more similar |
490
+ | Euclidean | `'euclidean'` | Straight-line distance between vector endpoints | Lower = more similar |
491
+ | Dot Product | `'dotproduct'` | Measures both direction and magnitude alignment | Higher = more similar |
274
492
 
275
493
  ## Available Implementations
276
494
 
277
- | Package | Vector Database |
278
- |---|---|
279
- | `@memberjunction/ai-vectors-pinecone` | Pinecone |
495
+ | Package | Provider | Hybrid Search |
496
+ |---|---|---|
497
+ | `@memberjunction/ai-vectors-pinecone` | Pinecone | No |
280
498
 
281
- Create additional implementations by extending `VectorDBBase` and registering with MemberJunction's class factory.
499
+ Create additional implementations by extending `VectorDBBase` and optionally registering with MemberJunction's class factory.
282
500
 
283
501
  ## Dependencies
284
502
 
285
503
  | Package | Purpose |
286
504
  |---|---|
287
505
  | `@memberjunction/core` | Core MemberJunction functionality |
288
- | `@memberjunction/global` | Global utilities |
506
+ | `@memberjunction/global` | Global utilities and class registration |
289
507
 
290
508
  ## Development
291
509
 
292
510
  ```bash
293
511
  # Build
512
+ cd packages/AI/Vectors/Database
294
513
  npm run build
295
514
 
296
- # Development mode
297
- npm run start
515
+ # Run tests
516
+ npm run test
517
+
518
+ # Watch mode
519
+ npm run test:watch
298
520
  ```
299
521
 
300
522
  ## License
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @fileoverview Metadata filter support for the shared Knowledge Hub vector index.
3
+ *
4
+ * Provides a `VectorMetadataFilter` utility that converts high-level
5
+ * filter options into provider-native filter objects suitable for
6
+ * passing to `VectorDBBase.QueryIndex()`.
7
+ *
8
+ * @module @memberjunction/ai-vectordb
9
+ */
10
+ /**
11
+ * Classification of how the vectorized content originated.
12
+ * Mirrors the type in @memberjunction/ai-vectors for package independence.
13
+ */
14
+ export type VectorSourceType = 'entity' | 'content-item' | 'file' | 'web-page';
15
+ /**
16
+ * Filter options for querying the shared vector index.
17
+ * All fields are optional -- omitted fields mean "no filter on this dimension".
18
+ * Mirrors the interface in @memberjunction/ai-vectors for package independence.
19
+ */
20
+ export interface SharedIndexFilterOptions {
21
+ /** Restrict to specific entity names */
22
+ EntityNames?: string[];
23
+ /** Restrict to specific source types */
24
+ SourceTypes?: VectorSourceType[];
25
+ /** Restrict to specific MIME content types */
26
+ ContentTypes?: string[];
27
+ /** Require all specified tags to be present */
28
+ Tags?: string[];
29
+ /** Restrict to specific Entity Document IDs */
30
+ EntityDocumentIDs?: string[];
31
+ }
32
+ /**
33
+ * Describes the structure of a single metadata filter condition.
34
+ * Each vector DB provider translates these into its native filter syntax.
35
+ */
36
+ export interface MetadataFilterCondition {
37
+ /** The metadata field name to filter on */
38
+ Field: string;
39
+ /** The comparison operator */
40
+ Operator: 'eq' | 'in' | 'contains';
41
+ /** The value(s) to compare against */
42
+ Value: string | string[] | number;
43
+ }
44
+ /**
45
+ * Utility class for converting `SharedIndexFilterOptions` into a flat array
46
+ * of `MetadataFilterCondition` objects that vector DB providers can interpret.
47
+ */
48
+ export declare class VectorMetadataFilter {
49
+ /**
50
+ * Convert shared index filter options into an array of filter conditions.
51
+ * Providers should map these conditions to their native filter syntax
52
+ * (e.g., Pinecone metadata filters, Weaviate where clauses, etc.).
53
+ *
54
+ * @param options - The high-level filter options from the search request
55
+ * @returns An array of conditions; empty if no filters are specified
56
+ */
57
+ static BuildConditions(options: SharedIndexFilterOptions): MetadataFilterCondition[];
58
+ /**
59
+ * Convert filter conditions into a simple key-value filter object
60
+ * compatible with the existing `QueryParamsBase.filter` field.
61
+ *
62
+ * This produces a "Pinecone-style" filter using `$in` and `$eq` operators.
63
+ * Providers with different filter syntax should override or adapt.
64
+ *
65
+ * @param conditions - The array of filter conditions to convert
66
+ * @returns A plain object suitable for `QueryParamsBase.filter`
67
+ */
68
+ static ToNativeFilter(conditions: MetadataFilterCondition[]): Record<string, unknown>;
69
+ /**
70
+ * Convenience method that converts SharedIndexFilterOptions directly
71
+ * to a native filter object in one step.
72
+ *
73
+ * @param options - The high-level filter options
74
+ * @returns A native filter object, or undefined if no filters specified
75
+ */
76
+ static FromOptions(options: SharedIndexFilterOptions): Record<string, unknown> | undefined;
77
+ }
78
+ //# sourceMappingURL=MetadataFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetadataFilter.d.ts","sourceRoot":"","sources":["../../src/generic/MetadataFilter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,cAAc,GAAG,MAAM,GAAG,UAAU,CAAC;AAE/E;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACrC,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,wCAAwC;IACxC,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACjC,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,+CAA+C;IAC/C,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACpC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,CAAC;IACnC,sCAAsC;IACtC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;CACrC;AAED;;;GAGG;AACH,qBAAa,oBAAoB;IAC7B;;;;;;;OAOG;WACW,eAAe,CAAC,OAAO,EAAE,wBAAwB,GAAG,uBAAuB,EAAE;IAgD3F;;;;;;;;;OASG;WACW,cAAc,CAAC,UAAU,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAqB5F;;;;;;OAMG;WACW,WAAW,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;CAOpG"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @fileoverview Metadata filter support for the shared Knowledge Hub vector index.
3
+ *
4
+ * Provides a `VectorMetadataFilter` utility that converts high-level
5
+ * filter options into provider-native filter objects suitable for
6
+ * passing to `VectorDBBase.QueryIndex()`.
7
+ *
8
+ * @module @memberjunction/ai-vectordb
9
+ */
10
+ /**
11
+ * Utility class for converting `SharedIndexFilterOptions` into a flat array
12
+ * of `MetadataFilterCondition` objects that vector DB providers can interpret.
13
+ */
14
+ export class VectorMetadataFilter {
15
+ /**
16
+ * Convert shared index filter options into an array of filter conditions.
17
+ * Providers should map these conditions to their native filter syntax
18
+ * (e.g., Pinecone metadata filters, Weaviate where clauses, etc.).
19
+ *
20
+ * @param options - The high-level filter options from the search request
21
+ * @returns An array of conditions; empty if no filters are specified
22
+ */
23
+ static BuildConditions(options) {
24
+ const conditions = [];
25
+ if (options.EntityNames && options.EntityNames.length > 0) {
26
+ conditions.push({
27
+ Field: 'EntityName',
28
+ Operator: 'in',
29
+ Value: options.EntityNames,
30
+ });
31
+ }
32
+ if (options.SourceTypes && options.SourceTypes.length > 0) {
33
+ conditions.push({
34
+ Field: 'SourceType',
35
+ Operator: 'in',
36
+ Value: options.SourceTypes,
37
+ });
38
+ }
39
+ if (options.ContentTypes && options.ContentTypes.length > 0) {
40
+ conditions.push({
41
+ Field: 'ContentType',
42
+ Operator: 'in',
43
+ Value: options.ContentTypes,
44
+ });
45
+ }
46
+ if (options.Tags && options.Tags.length > 0) {
47
+ for (const tag of options.Tags) {
48
+ conditions.push({
49
+ Field: 'Tags',
50
+ Operator: 'contains',
51
+ Value: tag,
52
+ });
53
+ }
54
+ }
55
+ if (options.EntityDocumentIDs && options.EntityDocumentIDs.length > 0) {
56
+ conditions.push({
57
+ Field: 'EntityDocumentID',
58
+ Operator: 'in',
59
+ Value: options.EntityDocumentIDs,
60
+ });
61
+ }
62
+ return conditions;
63
+ }
64
+ /**
65
+ * Convert filter conditions into a simple key-value filter object
66
+ * compatible with the existing `QueryParamsBase.filter` field.
67
+ *
68
+ * This produces a "Pinecone-style" filter using `$in` and `$eq` operators.
69
+ * Providers with different filter syntax should override or adapt.
70
+ *
71
+ * @param conditions - The array of filter conditions to convert
72
+ * @returns A plain object suitable for `QueryParamsBase.filter`
73
+ */
74
+ static ToNativeFilter(conditions) {
75
+ const filter = {};
76
+ for (const condition of conditions) {
77
+ switch (condition.Operator) {
78
+ case 'eq':
79
+ filter[condition.Field] = { $eq: condition.Value };
80
+ break;
81
+ case 'in':
82
+ filter[condition.Field] = { $in: condition.Value };
83
+ break;
84
+ case 'contains':
85
+ // For array fields, "contains" checks if the value is in the array
86
+ filter[condition.Field] = { $eq: condition.Value };
87
+ break;
88
+ }
89
+ }
90
+ return filter;
91
+ }
92
+ /**
93
+ * Convenience method that converts SharedIndexFilterOptions directly
94
+ * to a native filter object in one step.
95
+ *
96
+ * @param options - The high-level filter options
97
+ * @returns A native filter object, or undefined if no filters specified
98
+ */
99
+ static FromOptions(options) {
100
+ const conditions = VectorMetadataFilter.BuildConditions(options);
101
+ if (conditions.length === 0) {
102
+ return undefined;
103
+ }
104
+ return VectorMetadataFilter.ToNativeFilter(conditions);
105
+ }
106
+ }
107
+ //# sourceMappingURL=MetadataFilter.js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AC3D,CAAC;CACJ"}
@@ -1,25 +1,66 @@
1
1
  import { BaseRequestParams, BaseResponse, CreateIndexParams, EditIndexParams, IndexList, UpdateOptions, VectorRecord } from "./record.js";
2
- import { QueryOptions } from './query.types.js';
2
+ import { HybridQueryOptions, QueryOptions } from './query.types.js';
3
+ import { SharedIndexFilterOptions } from './MetadataFilter.js';
3
4
  export declare abstract class VectorDBBase {
4
5
  private _apiKey;
5
6
  /**
6
7
  * Only sub-classes can access the API key
7
8
  */
8
- protected get apiKey(): string;
9
+ protected get ApiKey(): string;
9
10
  constructor(apiKey: string);
10
- abstract listIndexes(): IndexList | Promise<IndexList>;
11
- abstract getIndex(params: BaseRequestParams): BaseResponse | Promise<BaseResponse>;
12
- abstract createIndex(params: CreateIndexParams): BaseResponse | Promise<BaseResponse>;
13
- abstract deleteIndex(params: BaseRequestParams): BaseResponse | Promise<BaseResponse>;
14
- abstract editIndex(params: EditIndexParams): BaseResponse | Promise<BaseResponse>;
15
- abstract queryIndex(params: QueryOptions): BaseResponse | Promise<BaseResponse>;
16
- abstract createRecord(record: VectorRecord): BaseResponse | Promise<BaseResponse>;
17
- abstract createRecords(record: VectorRecord[]): BaseResponse | Promise<BaseResponse>;
18
- abstract getRecord(param: BaseRequestParams): BaseResponse | Promise<BaseResponse>;
19
- abstract getRecords(params: BaseRequestParams): BaseResponse | Promise<BaseResponse>;
20
- abstract updateRecord(record: UpdateOptions): BaseResponse | Promise<BaseResponse>;
21
- abstract updateRecords(records: UpdateOptions): BaseResponse | Promise<BaseResponse>;
22
- abstract deleteRecord(record: VectorRecord): BaseResponse | Promise<BaseResponse>;
23
- abstract deleteRecords(records: VectorRecord[]): BaseResponse | Promise<BaseResponse>;
11
+ abstract ListIndexes(): IndexList | Promise<IndexList>;
12
+ abstract GetIndex(params: BaseRequestParams): BaseResponse | Promise<BaseResponse>;
13
+ abstract CreateIndex(params: CreateIndexParams): BaseResponse | Promise<BaseResponse>;
14
+ abstract DeleteIndex(params: BaseRequestParams): BaseResponse | Promise<BaseResponse>;
15
+ abstract EditIndex(params: EditIndexParams): BaseResponse | Promise<BaseResponse>;
16
+ abstract QueryIndex(params: QueryOptions): BaseResponse | Promise<BaseResponse>;
17
+ abstract CreateRecord(record: VectorRecord, indexName?: string): BaseResponse | Promise<BaseResponse>;
18
+ abstract CreateRecords(records: VectorRecord[], indexName?: string): BaseResponse | Promise<BaseResponse>;
19
+ abstract GetRecord(param: BaseRequestParams): BaseResponse | Promise<BaseResponse>;
20
+ abstract GetRecords(params: BaseRequestParams): BaseResponse | Promise<BaseResponse>;
21
+ abstract UpdateRecord(record: UpdateOptions): BaseResponse | Promise<BaseResponse>;
22
+ abstract UpdateRecords(records: UpdateOptions): BaseResponse | Promise<BaseResponse>;
23
+ abstract DeleteRecord(record: VectorRecord, indexName?: string): BaseResponse | Promise<BaseResponse>;
24
+ abstract DeleteRecords(records: VectorRecord[], indexName?: string): BaseResponse | Promise<BaseResponse>;
25
+ /**
26
+ * Delete ALL records from an index. Use with caution.
27
+ * @param indexName The name of the index to clear
28
+ * @param namespace Optional namespace within the index
29
+ */
30
+ abstract DeleteAllRecords(indexName: string, namespace?: string): BaseResponse | Promise<BaseResponse>;
31
+ /**
32
+ * Whether this provider supports hybrid (vector + keyword) search.
33
+ * Override and return true in providers that implement HybridQuery().
34
+ */
35
+ get SupportsHybridSearch(): boolean;
36
+ /**
37
+ * Perform a hybrid search combining vector similarity with keyword (BM25) matching.
38
+ * Only available on providers where SupportsHybridSearch is true.
39
+ * Default implementation falls back to a standard vector QueryIndex call.
40
+ */
41
+ HybridQuery(params: HybridQueryOptions): BaseResponse | Promise<BaseResponse>;
42
+ /**
43
+ * Query the vector index with metadata filtering using SharedIndexFilterOptions.
44
+ *
45
+ * Default implementation converts the filter options to a native filter object
46
+ * and delegates to QueryIndex. Providers can override BuildMetadataFilter()
47
+ * for custom filter syntax.
48
+ *
49
+ * @param params - Standard query options with an additional metadataFilter field
50
+ * @returns The query response from the vector database
51
+ */
52
+ MetadataFilteredQuery(params: QueryOptions & {
53
+ metadataFilter: SharedIndexFilterOptions;
54
+ }): BaseResponse | Promise<BaseResponse>;
55
+ /**
56
+ * Convert SharedIndexFilterOptions to a provider-native filter object.
57
+ *
58
+ * Override this method in provider subclasses to produce provider-specific
59
+ * filter syntax (e.g., Pinecone, Weaviate, Qdrant, etc.).
60
+ *
61
+ * @param options - The high-level filter options
62
+ * @returns A native filter object, or undefined if no filters
63
+ */
64
+ BuildMetadataFilter(options: SharedIndexFilterOptions): object | undefined;
24
65
  }
25
66
  //# sourceMappingURL=VectorDBBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VectorDBBase.d.ts","sourceRoot":"","sources":["../../src/generic/VectorDBBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EACnD,eAAe,EAAE,SAAS,EAAE,aAAa,EACzC,YAAY,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,8BAAsB,YAAY;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB;;OAEG;IACH,SAAS,KAAK,MAAM,IAAI,MAAM,CAE7B;gBAEY,MAAM,EAAE,MAAM;IAQ3B,QAAQ,CAAC,WAAW,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACtD,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAClF,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IACrF,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IACrF,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,GAAI,OAAO,CAAC,YAAY,CAAC;IAClF,QAAQ,CAA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AC,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAI,OAAO,CAAC,YAAY,CAAC;IACtG,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAI,OAAO,CAAC,YAAY,CAAC;IAE1G;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAEtG;;;OAGG;IACH,IAAW,oBAAoB,IAAI,OAAO,CAEzC;IAED;;;;OAIG;IACI,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAKpF;;;;;;;;;OASG;IACI,qBAAqB,CACxB,MAAM,EAAE,YAAY,GAAG;QAAE,cAAc,EAAE,wBAAwB,CAAA;KAAE,GACpE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAWvC;;;;;;;;OAQG;IACI,mBAAmB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,GAAG,SAAS;CAGpF"}
@@ -1,8 +1,9 @@
1
+ import { VectorMetadataFilter } from './MetadataFilter.js';
1
2
  export class VectorDBBase {
2
3
  /**
3
4
  * Only sub-classes can access the API key
4
5
  */
5
- get apiKey() {
6
+ get ApiKey() {
6
7
  return this._apiKey;
7
8
  }
8
9
  constructor(apiKey) {
@@ -10,5 +11,53 @@ export class VectorDBBase {
10
11
  throw new Error('API key cannot be empty');
11
12
  this._apiKey = apiKey;
12
13
  }
14
+ /**
15
+ * Whether this provider supports hybrid (vector + keyword) search.
16
+ * Override and return true in providers that implement HybridQuery().
17
+ */
18
+ get SupportsHybridSearch() {
19
+ return false;
20
+ }
21
+ /**
22
+ * Perform a hybrid search combining vector similarity with keyword (BM25) matching.
23
+ * Only available on providers where SupportsHybridSearch is true.
24
+ * Default implementation falls back to a standard vector QueryIndex call.
25
+ */
26
+ HybridQuery(params) {
27
+ // Default: fall back to pure vector search, ignoring keyword params
28
+ return this.QueryIndex({ vector: params.vector, topK: params.topK, includeMetadata: params.includeMetadata, includeValues: params.includeValues, filter: params.filter });
29
+ }
30
+ /**
31
+ * Query the vector index with metadata filtering using SharedIndexFilterOptions.
32
+ *
33
+ * Default implementation converts the filter options to a native filter object
34
+ * and delegates to QueryIndex. Providers can override BuildMetadataFilter()
35
+ * for custom filter syntax.
36
+ *
37
+ * @param params - Standard query options with an additional metadataFilter field
38
+ * @returns The query response from the vector database
39
+ */
40
+ MetadataFilteredQuery(params) {
41
+ const nativeFilter = this.BuildMetadataFilter(params.metadataFilter);
42
+ const queryParams = {
43
+ ...params,
44
+ filter: nativeFilter ?? params.filter,
45
+ };
46
+ // Remove the metadataFilter before passing to QueryIndex
47
+ delete queryParams['metadataFilter'];
48
+ return this.QueryIndex(queryParams);
49
+ }
50
+ /**
51
+ * Convert SharedIndexFilterOptions to a provider-native filter object.
52
+ *
53
+ * Override this method in provider subclasses to produce provider-specific
54
+ * filter syntax (e.g., Pinecone, Weaviate, Qdrant, etc.).
55
+ *
56
+ * @param options - The high-level filter options
57
+ * @returns A native filter object, or undefined if no filters
58
+ */
59
+ BuildMetadataFilter(options) {
60
+ return VectorMetadataFilter.FromOptions(options);
61
+ }
13
62
  }
14
63
  //# sourceMappingURL=VectorDBBase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VectorDBBase.js","sourceRoot":"","sources":["../../src/generic/VectorDBBase.ts"],"names":[],"mappings":"AAKA,MAAM,OAAgB,YAAY;IAE9B;;OAEG;IACH,IAAc,MAAM;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,YAAa,MAAc;QACvB,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CA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AAC;IACxC,CAAC;IAED;;;;;;;;OAQG;IACI,mBAAmB,CAAC,OAAiC;QACxD,OAAO,oBAAoB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;CACJ"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Configuration interfaces for VectorDatabase and VectorIndex provider settings.
3
+ *
4
+ * These are stored as JSON in the Configuration / ProviderConfig columns and
5
+ * parsed at runtime. All fields are optional — NULL or missing means "use
6
+ * provider/environment defaults."
7
+ */
8
+ /**
9
+ * Provider-level configuration for a VectorDatabase record.
10
+ * Stored in VectorDatabase.Configuration as JSON.
11
+ *
12
+ * Controls connection behavior, resilience, and throughput limits that
13
+ * apply to every index managed by this database provider instance.
14
+ */
15
+ export interface VectorDatabaseConfiguration {
16
+ /** Connection settings — host overrides, timeouts, proxy */
17
+ connection?: VectorDatabaseConnectionConfig;
18
+ /** Retry / resilience behavior for transient failures */
19
+ resilience?: VectorDatabaseResilienceConfig;
20
+ /** Throughput caps that the provider should respect */
21
+ throughput?: VectorDatabaseThroughputConfig;
22
+ }
23
+ export interface VectorDatabaseConnectionConfig {
24
+ /**
25
+ * Custom API host/endpoint URL. Overrides the default derived from
26
+ * environment variables (e.g. PINECONE_HOST).
27
+ * Useful for private endpoints, proxies, or region overrides.
28
+ */
29
+ hostUrl?: string;
30
+ /**
31
+ * Request timeout in milliseconds for individual API calls.
32
+ * Default varies by provider (typically 30 000 ms).
33
+ */
34
+ requestTimeoutMs?: number;
35
+ /**
36
+ * Connection timeout in milliseconds — how long to wait for a
37
+ * TCP connection to be established.
38
+ */
39
+ connectTimeoutMs?: number;
40
+ /**
41
+ * HTTP/SOCKS proxy URL (e.g. "http://proxy.corp:8080").
42
+ * Only applies to providers that support proxy configuration.
43
+ */
44
+ proxyUrl?: string;
45
+ }
46
+ export interface VectorDatabaseResilienceConfig {
47
+ /**
48
+ * Maximum number of retries on transient failures (429, 5xx).
49
+ * Set to 0 to disable retries. Default: 3.
50
+ */
51
+ maxRetries?: number;
52
+ /**
53
+ * Base delay in ms for exponential backoff between retries.
54
+ * Actual delay = baseDelayMs * 2^(attempt). Default: 500.
55
+ */
56
+ retryBaseDelayMs?: number;
57
+ /**
58
+ * Maximum delay in ms between retries (caps the exponential
59
+ * backoff). Default: 30 000.
60
+ */
61
+ retryMaxDelayMs?: number;
62
+ }
63
+ export interface VectorDatabaseThroughputConfig {
64
+ /**
65
+ * Maximum number of vectors in a single upsert batch.
66
+ * Pinecone recommends ≤100; other providers may differ.
67
+ */
68
+ maxUpsertBatchSize?: number;
69
+ /**
70
+ * Maximum number of concurrent API requests to the provider.
71
+ * Helps avoid rate-limit errors on shared-tier plans.
72
+ */
73
+ maxConcurrentRequests?: number;
74
+ /**
75
+ * Hard ceiling on requests per second. The client will
76
+ * throttle to stay under this limit. 0 = unlimited.
77
+ */
78
+ maxRequestsPerSecond?: number;
79
+ }
80
+ /**
81
+ * Index-level provider configuration stored in VectorIndex.ProviderConfig
82
+ * as JSON. Currently populated by the server entity hook when an index
83
+ * is auto-provisioned, and may also be edited manually.
84
+ *
85
+ * Contains both read-back fields (ExternalID, Dimensions, Metric set by
86
+ * the hook) and tunable settings.
87
+ */
88
+ export interface VectorIndexProviderConfig {
89
+ /**
90
+ * The provider-assigned identifier for this index (e.g. Pinecone
91
+ * index host URL or Weaviate class name). Written by the server
92
+ * hook after provisioning.
93
+ */
94
+ ExternalID?: string;
95
+ /**
96
+ * Dimensionality of vectors stored in this index.
97
+ * Written by the server hook from the embedding model.
98
+ */
99
+ Dimensions?: number;
100
+ /**
101
+ * Distance metric used for similarity search.
102
+ * Written by the server hook from VectorIndex.DistanceMetric.
103
+ */
104
+ Metric?: string;
105
+ /** Provisioning and capacity settings (provider-specific) */
106
+ provisioning?: VectorIndexProvisioningConfig;
107
+ /** Default query parameters applied when not overridden per-call */
108
+ queryDefaults?: VectorIndexQueryDefaults;
109
+ /** Namespace mapping strategy for multi-tenant or multi-entity indexes */
110
+ namespaceStrategy?: VectorIndexNamespaceStrategy;
111
+ /** Per-record metadata constraints */
112
+ metadataLimits?: VectorIndexMetadataLimits;
113
+ }
114
+ export interface VectorIndexProvisioningConfig {
115
+ /**
116
+ * Deployment type. Pinecone supports "serverless" and "pod".
117
+ * Other providers may use different terminology.
118
+ */
119
+ deploymentType?: 'serverless' | 'pod' | string;
120
+ /** Cloud provider for serverless indexes (e.g. "aws", "gcp", "azure") */
121
+ cloud?: string;
122
+ /** Cloud region (e.g. "us-east-1", "us-west-2") */
123
+ region?: string;
124
+ /**
125
+ * Pod type (e.g. "p1.x1", "s1.x2"). Only relevant for pod-based
126
+ * deployments.
127
+ */
128
+ podType?: string;
129
+ /** Number of replicas for high-availability. Pod-based only. */
130
+ replicas?: number;
131
+ /** Number of shards for horizontal scaling. Pod-based only. */
132
+ shards?: number;
133
+ }
134
+ export interface VectorIndexQueryDefaults {
135
+ /**
136
+ * Default number of results to return. Overridden by explicit
137
+ * topK in individual queries.
138
+ */
139
+ topK?: number;
140
+ /** Whether to include metadata in query results by default */
141
+ includeMetadata?: boolean;
142
+ /** Whether to include vector values in query results by default */
143
+ includeValues?: boolean;
144
+ }
145
+ export interface VectorIndexNamespaceStrategy {
146
+ /**
147
+ * How namespaces are assigned:
148
+ * - "none": single flat namespace (default)
149
+ * - "per-entity": one namespace per entity name
150
+ * - "per-tenant": one namespace per organization/tenant ID
151
+ * - "custom": driven by a custom function or template
152
+ */
153
+ mode?: 'none' | 'per-entity' | 'per-tenant' | 'custom';
154
+ /**
155
+ * Template string for custom namespace names.
156
+ * Supports {{EntityName}}, {{TenantID}}, {{EntityDocumentID}}.
157
+ * Only used when mode = "custom".
158
+ */
159
+ template?: string;
160
+ }
161
+ export interface VectorIndexMetadataLimits {
162
+ /**
163
+ * Maximum total metadata size in bytes per record.
164
+ * Pinecone free tier: 40 KB. Paid: 40 KB default.
165
+ * Records exceeding this will have large fields truncated.
166
+ */
167
+ maxMetadataBytesPerRecord?: number;
168
+ /**
169
+ * Maximum number of metadata fields per record.
170
+ * Some providers cap this (e.g. Pinecone: no hard cap but
171
+ * performance degrades past ~40 fields).
172
+ */
173
+ maxMetadataFields?: number;
174
+ }
175
+ //# sourceMappingURL=configuration.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.types.d.ts","sourceRoot":"","sources":["../../src/generic/configuration.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B;IACxC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,8BAA8B,CAAC;IAE5C,yDAAyD;IACzD,UAAU,CAAC,EAAE,8BAA8B,CAAC;IAE5C,uDAAuD;IACvD,UAAU,CAAC,EAAE,8BAA8B,CAAC;CAC/C;AAED,MAAM,WAAW,8BAA8B;IAC3C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,8BAA8B;IAC3C;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,8BAA8B;IAC3C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,6BAA6B,CAAC;IAE7C,oEAAoE;IACpE,aAAa,CAAC,EAAE,wBAAwB,CAAC;IAEzC,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,4BAA4B,CAAC;IAEjD,sCAAsC;IACtC,cAAc,CAAC,EAAE,yBAAyB,CAAC;CAC9C;AAED,MAAM,WAAW,6BAA6B;IAC1C;;;OAGG;IACH,cAAc,CAAC,EAAE,YAAY,GAAG,KAAK,GAAG,MAAM,CAAC;IAE/C,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACrC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,8DAA8D;IAC9D,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,mEAAmE;IACnE,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,4BAA4B;IACzC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,QAAQ,CAAC;IAEvD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,yBAAyB;IACtC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Configuration interfaces for VectorDatabase and VectorIndex provider settings.
3
+ *
4
+ * These are stored as JSON in the Configuration / ProviderConfig columns and
5
+ * parsed at runtime. All fields are optional — NULL or missing means "use
6
+ * provider/environment defaults."
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=configuration.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.types.js","sourceRoot":"","sources":["../../src/generic/configuration.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -40,6 +40,20 @@ export type QueryByVectorValues = QueryParamsBase & {
40
40
  * The options that may be passed to {@link VectorDBBase.queryIndex }
41
41
  */
42
42
  export type QueryOptions = QueryByRecordId | QueryByVectorValues;
43
+ /**
44
+ * Options for hybrid search combining vector similarity with keyword (BM25) search.
45
+ * Providers that support hybrid search implement VectorDBBase.HybridQuery().
46
+ */
47
+ export interface HybridQueryOptions extends QueryParamsBase {
48
+ /** Vector values for the semantic similarity component */
49
+ vector: RecordValues;
50
+ /** Keyword query string for the BM25/text search component */
51
+ KeywordQuery?: string;
52
+ /** Balance between vector and keyword: 0.0 = pure keyword, 1.0 = pure vector (default: 0.7) */
53
+ Alpha?: number;
54
+ /** Method for fusing vector and keyword result lists (default: 'rrf') */
55
+ FusionMethod?: 'rrf' | 'weighted';
56
+ }
43
57
  export interface ScoredRecord<T extends RecordMetadata = RecordMetadata> extends VectorRecord<T> {
44
58
  /**
45
59
  * The similarity score of the record. The interpretation of this score will be different
@@ -1 +1 @@
1
- {"version":3,"file":"query.types.d.ts","sourceRoot":"","sources":["../../src/generic/query.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGtE,MAAM,MAAM,eAAe,GAAG;IAC1B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,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,MAAM,eAAe,GAAG,iBAAiB,GAAG,EACjD,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI;IACnE,oDAAoD;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;OACG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAIhB,IAAI,EAAE,GAAG,CAAA;CACZ,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './generic/record.js';
2
2
  export * from './generic/VectorDBBase.js';
3
3
  export * from './generic/query.types.js';
4
+ export * from './generic/MetadataFilter.js';
5
+ export * from './generic/configuration.types.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './generic/record.js';
2
2
  export * from './generic/VectorDBBase.js';
3
3
  export * from './generic/query.types.js';
4
+ export * from './generic/MetadataFilter.js';
5
+ export * from './generic/configuration.types.js';
4
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/ai-vectordb",
3
3
  "type": "module",
4
- "version": "5.20.0",
4
+ "version": "5.22.0",
5
5
  "description": "MemberJunction: AI Vector Database Module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -17,8 +17,8 @@
17
17
  "author": "MemberJunction.com",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@memberjunction/core": "5.20.0",
21
- "@memberjunction/global": "5.20.0",
20
+ "@memberjunction/core": "5.22.0",
21
+ "@memberjunction/global": "5.22.0",
22
22
  "dotenv": "^17.2.4"
23
23
  },
24
24
  "devDependencies": {