@delali/narsil 0.1.1 → 0.1.2
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 +39 -0
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/{chunk-JKIBUPAY.mjs → chunk-7GKPWGCN.mjs} +2 -1
- package/dist/chunk-GVN2W4VA.mjs +570 -0
- package/dist/chunk-HRABJLPB.mjs +64 -0
- package/dist/{chunk-5HXMVMSM.mjs → chunk-LIRVYUQ5.mjs} +1174 -181
- package/dist/direct-executor-DFRFDLFP.mjs +4 -0
- package/dist/index.d.ts +46 -3
- package/dist/index.mjs +1367 -415
- package/dist/vector/hnsw-build-worker.d.ts +37 -0
- package/dist/vector/hnsw-build-worker.mjs +81 -0
- package/dist/workers/entry.mjs +3 -32
- package/package.json +17 -11
- package/dist/chunk-N37VMC62.mjs +0 -18
- package/dist/direct-executor-MQD7JRD4.mjs +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare const ErrorCodes: {
|
|
|
30
30
|
readonly LANGUAGE_NOT_SUPPORTED: "LANGUAGE_NOT_SUPPORTED";
|
|
31
31
|
readonly ENVELOPE_VERSION_MISMATCH: "ENVELOPE_VERSION_MISMATCH";
|
|
32
32
|
readonly ENVELOPE_INVALID_MAGIC: "ENVELOPE_INVALID_MAGIC";
|
|
33
|
+
readonly PARTITION_CAPACITY_EXCEEDED: "PARTITION_CAPACITY_EXCEEDED";
|
|
33
34
|
};
|
|
34
35
|
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
35
36
|
declare class NarsilError extends Error {
|
|
@@ -48,6 +49,15 @@ type FieldType = 'string' | 'number' | 'boolean' | 'enum' | 'geopoint' | `vector
|
|
|
48
49
|
type SchemaDefinition = {
|
|
49
50
|
[field: string]: FieldType | SchemaDefinition;
|
|
50
51
|
};
|
|
52
|
+
interface VectorPromotionConfig {
|
|
53
|
+
threshold?: number;
|
|
54
|
+
hnswConfig?: {
|
|
55
|
+
m?: number;
|
|
56
|
+
efConstruction?: number;
|
|
57
|
+
metric?: 'cosine' | 'dotProduct' | 'euclidean';
|
|
58
|
+
};
|
|
59
|
+
workerStrategy?: 'worker-threads' | 'web-worker' | 'synchronous';
|
|
60
|
+
}
|
|
51
61
|
interface IndexConfig {
|
|
52
62
|
schema: SchemaDefinition;
|
|
53
63
|
language?: string;
|
|
@@ -56,6 +66,9 @@ interface IndexConfig {
|
|
|
56
66
|
bm25?: BM25Params;
|
|
57
67
|
stopWords?: Set<string> | ((defaults: Set<string>) => Set<string>);
|
|
58
68
|
tokenizer?: CustomTokenizer;
|
|
69
|
+
trackPositions?: boolean;
|
|
70
|
+
vectorPromotion?: VectorPromotionConfig;
|
|
71
|
+
strict?: boolean;
|
|
59
72
|
}
|
|
60
73
|
interface BM25Params {
|
|
61
74
|
k1?: number;
|
|
@@ -72,6 +85,9 @@ interface PartitionConfig {
|
|
|
72
85
|
maxPartitions?: number;
|
|
73
86
|
}
|
|
74
87
|
type ScoringMode = 'local' | 'dfs' | 'broadcast';
|
|
88
|
+
interface InsertOptions {
|
|
89
|
+
skipClone?: boolean;
|
|
90
|
+
}
|
|
75
91
|
|
|
76
92
|
interface QueryResult<T = AnyDocument> {
|
|
77
93
|
hits: Array<Hit<T>>;
|
|
@@ -133,6 +149,20 @@ interface IndexInfo {
|
|
|
133
149
|
partitionCount: number;
|
|
134
150
|
language: string;
|
|
135
151
|
}
|
|
152
|
+
interface PartitionStatsResult {
|
|
153
|
+
partitionId: number;
|
|
154
|
+
documentCount: number;
|
|
155
|
+
estimatedMemoryBytes: number;
|
|
156
|
+
vectorFieldCount: number;
|
|
157
|
+
isHnswPromoted: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface SuggestResult {
|
|
160
|
+
terms: Array<{
|
|
161
|
+
term: string;
|
|
162
|
+
documentFrequency: number;
|
|
163
|
+
}>;
|
|
164
|
+
elapsed: number;
|
|
165
|
+
}
|
|
136
166
|
interface MemoryStats {
|
|
137
167
|
totalBytes: number;
|
|
138
168
|
workers: Array<{
|
|
@@ -224,6 +254,7 @@ interface QueryParams {
|
|
|
224
254
|
mode?: SearchMode;
|
|
225
255
|
vector?: VectorQueryConfig;
|
|
226
256
|
hybrid?: HybridConfig;
|
|
257
|
+
includeScoreComponents?: boolean;
|
|
227
258
|
}
|
|
228
259
|
interface VectorQueryConfig {
|
|
229
260
|
field: string;
|
|
@@ -260,6 +291,10 @@ interface HighlightConfig {
|
|
|
260
291
|
postTag?: string;
|
|
261
292
|
maxSnippetLength?: number;
|
|
262
293
|
}
|
|
294
|
+
interface SuggestParams {
|
|
295
|
+
prefix: string;
|
|
296
|
+
limit?: number;
|
|
297
|
+
}
|
|
263
298
|
|
|
264
299
|
interface NarsilPlugin {
|
|
265
300
|
name: string;
|
|
@@ -358,8 +393,9 @@ interface Narsil {
|
|
|
358
393
|
dropIndex(name: string): Promise<void>;
|
|
359
394
|
listIndexes(): IndexInfo[];
|
|
360
395
|
getStats(indexName: string): IndexStats;
|
|
361
|
-
|
|
362
|
-
|
|
396
|
+
getPartitionStats(indexName: string): PartitionStatsResult[];
|
|
397
|
+
insert(indexName: string, document: AnyDocument, docId?: string, options?: InsertOptions): Promise<string>;
|
|
398
|
+
insertBatch(indexName: string, documents: AnyDocument[], options?: InsertOptions): Promise<BatchResult>;
|
|
363
399
|
remove(indexName: string, docId: string): Promise<void>;
|
|
364
400
|
removeBatch(indexName: string, docIds: string[]): Promise<BatchResult>;
|
|
365
401
|
update(indexName: string, docId: string, document: AnyDocument): Promise<void>;
|
|
@@ -373,7 +409,12 @@ interface Narsil {
|
|
|
373
409
|
countDocuments(indexName: string): Promise<number>;
|
|
374
410
|
query<T = AnyDocument>(indexName: string, params: QueryParams): Promise<QueryResult<T>>;
|
|
375
411
|
preflight(indexName: string, params: QueryParams): Promise<PreflightResult>;
|
|
412
|
+
suggest(indexName: string, params: SuggestParams): Promise<SuggestResult>;
|
|
413
|
+
snapshot(indexName: string): Promise<Uint8Array>;
|
|
414
|
+
restore(indexName: string, data: Uint8Array): Promise<void>;
|
|
376
415
|
clear(indexName: string): Promise<void>;
|
|
416
|
+
rebalance(indexName: string, targetPartitionCount: number): Promise<void>;
|
|
417
|
+
updatePartitionConfig(indexName: string, config: Partial<PartitionConfig>): Promise<void>;
|
|
377
418
|
getMemoryStats(): MemoryStats;
|
|
378
419
|
on<K extends keyof NarsilEventMap>(event: K, handler: (payload: NarsilEventMap[K]) => void): void;
|
|
379
420
|
off<K extends keyof NarsilEventMap>(event: K, handler: (payload: NarsilEventMap[K]) => void): void;
|
|
@@ -381,6 +422,8 @@ interface Narsil {
|
|
|
381
422
|
}
|
|
382
423
|
declare function createNarsil(config?: NarsilConfig): Promise<Narsil>;
|
|
383
424
|
|
|
425
|
+
declare function isSimdAvailable(): boolean;
|
|
426
|
+
|
|
384
427
|
declare const VERSION = "0.1.0";
|
|
385
428
|
|
|
386
|
-
export { type AnyDocument, type ArrayFilter, type BM25Params, type BatchResult, type ComparisonFilter, type CustomTokenizer, type ErrorCode, ErrorCodes, type FacetConfig, type FacetResult, type FieldType, type FilterExpression, type FlushConfig, type GeoPolygonFilter, type GeoRadiusFilter, type GroupConfig, type GroupReducer, type GroupResult, type HighlightConfig, type HighlightMatch, type Hit, type HybridConfig, type IndexConfig, type IndexContext, type IndexInfo, type IndexStats, type InsertContext, InvalidationAdapter, LanguageModule, type MemoryStats, type Narsil, type NarsilConfig, NarsilError, type NarsilEventMap, type NarsilPlugin, type PartitionConfig, type PartitionContext, PersistenceAdapter, type PreflightResult, type PresenceFilter, type QueryParams, type QueryResult, type RemoveContext, type SchemaDefinition, type ScoreComponents, type ScoringMode, type SearchContext, type SearchMode, type StringFilter, type TermMatchPolicy, type UpdateContext, VERSION, type VectorQueryConfig, type WorkerConfig, type WorkerContext, createNarsil, getLanguage, registerLanguage };
|
|
429
|
+
export { type AnyDocument, type ArrayFilter, type BM25Params, type BatchResult, type ComparisonFilter, type CustomTokenizer, type ErrorCode, ErrorCodes, type FacetConfig, type FacetResult, type FieldType, type FilterExpression, type FlushConfig, type GeoPolygonFilter, type GeoRadiusFilter, type GroupConfig, type GroupReducer, type GroupResult, type HighlightConfig, type HighlightMatch, type Hit, type HybridConfig, type IndexConfig, type IndexContext, type IndexInfo, type IndexStats, type InsertContext, type InsertOptions, InvalidationAdapter, LanguageModule, type MemoryStats, type Narsil, type NarsilConfig, NarsilError, type NarsilEventMap, type NarsilPlugin, type PartitionConfig, type PartitionContext, type PartitionStatsResult, PersistenceAdapter, type PreflightResult, type PresenceFilter, type QueryParams, type QueryResult, type RemoveContext, type SchemaDefinition, type ScoreComponents, type ScoringMode, type SearchContext, type SearchMode, type StringFilter, type SuggestParams, type SuggestResult, type TermMatchPolicy, type UpdateContext, VERSION, type VectorQueryConfig, type WorkerConfig, type WorkerContext, createNarsil, getLanguage, isSimdAvailable, registerLanguage };
|