@omendb/omendb 0.0.5 → 0.0.6
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/index.d.ts +56 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -47,6 +47,49 @@ export declare class VectorDatabase {
|
|
|
47
47
|
collections(): Array<string>
|
|
48
48
|
/** Delete a collection. */
|
|
49
49
|
deleteCollection(name: string): void
|
|
50
|
+
/**
|
|
51
|
+
* Enable text search for hybrid (vector + text) search.
|
|
52
|
+
*
|
|
53
|
+
* Must be called before using setWithText() or hybridSearch().
|
|
54
|
+
*/
|
|
55
|
+
enableTextSearch(): void
|
|
56
|
+
/** Check if text search is enabled. */
|
|
57
|
+
get hasTextSearch(): boolean
|
|
58
|
+
/**
|
|
59
|
+
* Set vectors with associated text for hybrid search.
|
|
60
|
+
*
|
|
61
|
+
* @param items - Array of {id, vector, text, metadata?}
|
|
62
|
+
* @returns Array of internal indices
|
|
63
|
+
*/
|
|
64
|
+
setWithText(items: Array<VectorItemWithText>): Array<number>
|
|
65
|
+
/**
|
|
66
|
+
* Search using text only (BM25 scoring).
|
|
67
|
+
*
|
|
68
|
+
* @param query - Text query
|
|
69
|
+
* @param k - Number of results
|
|
70
|
+
* @returns Array of {id, score, metadata}
|
|
71
|
+
*/
|
|
72
|
+
textSearch(query: string, k: number): Array<TextSearchResult>
|
|
73
|
+
/**
|
|
74
|
+
* Hybrid search combining vector similarity and text relevance.
|
|
75
|
+
*
|
|
76
|
+
* Uses Reciprocal Rank Fusion (RRF) to combine HNSW and BM25 results.
|
|
77
|
+
*
|
|
78
|
+
* @param queryVector - Query embedding
|
|
79
|
+
* @param queryText - Text query for BM25
|
|
80
|
+
* @param k - Number of results
|
|
81
|
+
* @param filter - Optional metadata filter
|
|
82
|
+
* @param alpha - Weight for vector vs text (0.0=text only, 1.0=vector only, default=0.5)
|
|
83
|
+
* @param rrfK - RRF constant (default=60, higher reduces rank influence)
|
|
84
|
+
* @returns Array of {id, score, metadata}
|
|
85
|
+
*/
|
|
86
|
+
hybridSearch(queryVector: Array<number> | Float32Array, queryText: string, k: number, filter?: Record<string, unknown> | undefined, alpha?: number | undefined | null, rrfK?: number | undefined | null): Array<TextSearchResult>
|
|
87
|
+
/**
|
|
88
|
+
* Flush pending changes to disk.
|
|
89
|
+
*
|
|
90
|
+
* For hybrid search, this commits text index changes.
|
|
91
|
+
*/
|
|
92
|
+
flush(): void
|
|
50
93
|
/** Merge another database into this one. */
|
|
51
94
|
mergeFrom(other: VectorDatabase): number
|
|
52
95
|
}
|
|
@@ -119,6 +162,12 @@ export interface SearchResult {
|
|
|
119
162
|
metadata: Record<string, unknown>
|
|
120
163
|
}
|
|
121
164
|
|
|
165
|
+
export interface TextSearchResult {
|
|
166
|
+
id: string
|
|
167
|
+
score: number
|
|
168
|
+
metadata: Record<string, unknown>
|
|
169
|
+
}
|
|
170
|
+
|
|
122
171
|
export interface VectorItem {
|
|
123
172
|
id: string
|
|
124
173
|
/** Vector data as array of numbers */
|
|
@@ -128,3 +177,10 @@ export interface VectorItem {
|
|
|
128
177
|
/** Optional document text (stored in metadata.document) */
|
|
129
178
|
document?: string
|
|
130
179
|
}
|
|
180
|
+
|
|
181
|
+
export interface VectorItemWithText {
|
|
182
|
+
id: string
|
|
183
|
+
vector: Array<number>
|
|
184
|
+
text: string
|
|
185
|
+
metadata?: Record<string, unknown> | undefined
|
|
186
|
+
}
|