@wiscale/velesdb-sdk 1.14.4 → 1.15.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Official TypeScript SDK for [VelesDB](https://github.com/cyberlife-coder/VelesDB) -- the local-first vector database for AI and RAG. Sub-millisecond semantic search in Browser and Node.js.
4
4
 
5
- **v1.14.4** | Node.js >= 18 | Browser (WASM) | MIT License
5
+ **v1.15.0** | Node.js >= 18 | Browser (WASM) | MIT License
6
6
 
7
7
  ## What's New in v1.14.2
8
8
 
@@ -430,6 +430,37 @@ const results = await db.multiQuerySearch('docs', [emb1, emb2], {
430
430
 
431
431
  > **Note:** WASM supports `rrf`, `average`, `maximum`. The `weighted` and `relative_score` strategies are REST-only.
432
432
 
433
+ #### Named sparse indexes — `sparseIndexName` vs `sparseSearchNamed()`
434
+
435
+ A collection can carry multiple sparse indexes (e.g. `splade_v2`, `bm25_titles`). The TypeScript SDK exposes two distinct APIs depending on whether you want a dense + sparse hybrid query or a pure sparse query against a named index.
436
+
437
+ | API | Shape | Use when |
438
+ |---|---|---|
439
+ | `db.search(coll, denseVec, { sparseVector, sparseIndexName })` | dense + sparse hybrid against the named sparse index | You already have a dense embedding and want to combine it with a specific named sparse index in a single search call. The dense vector drives the primary candidate set; the named sparse index re-ranks. |
440
+ | `db.sparseSearchNamed(coll, sparseVec, indexName, options?)` | pure sparse against a named index | You have only a sparse vector (e.g. SPLADE expansion, lexical query) and want to query a specific named sparse index directly. No dense component. |
441
+
442
+ ```typescript
443
+ // Hybrid: dense + sparse via the splade_v2 named index
444
+ const hybrid = await db.search('docs', denseEmbedding, {
445
+ k: 10,
446
+ sparseVector: { 42: 0.8, 99: 0.3 },
447
+ sparseIndexName: 'splade_v2',
448
+ });
449
+
450
+ // Pure sparse against the same named index
451
+ const sparseOnly = await db.sparseSearchNamed(
452
+ 'docs',
453
+ { 42: 0.8, 99: 0.3 },
454
+ 'splade_v2',
455
+ { k: 10 },
456
+ );
457
+ ```
458
+
459
+ When the collection has only one (default) sparse index, omit `sparseIndexName` on `db.search()`; the server picks the default. For named indexes, both APIs require the explicit name.
460
+
461
+ > **Note:** Both APIs are REST-only when a named index is required.
462
+ > The WASM backend has no concept of named sparse indexes — `sparseIndexName` is silently ignored on `db.search()` (the collection's single sparse index is used), and `db.sparseSearchNamed()` throws `wasmNotSupported`. Tracked as a follow-up to either surface a `wasmNotSupported` throw on `sparseIndexName` or implement named-sparse support in WASM.
463
+
433
464
  ---
434
465
 
435
466
  ### Collection Utilities
package/dist/index.d.mts CHANGED
@@ -376,6 +376,30 @@ declare const f: {
376
376
  * @packageDocumentation
377
377
  */
378
378
 
379
+ /**
380
+ * Options for `db.sparseSearchNamed()` — **pure sparse** query against a
381
+ * named sparse index (issue #380).
382
+ *
383
+ * Use this when you have only a sparse vector and want to query a specific
384
+ * named sparse index directly. The query carries no dense component.
385
+ *
386
+ * For **dense + sparse hybrid** against a named index, use
387
+ * `db.search(..., { sparseVector, sparseIndexName })` instead
388
+ * (see {@link SearchOptions.sparseIndexName}).
389
+ *
390
+ * **Backend support:** REST only. The WASM backend has no concept of named
391
+ * sparse indexes; this method throws `wasmNotSupported` on WASM.
392
+ */
393
+ interface SparseSearchNamedOptions {
394
+ /** Number of results to return (default: 10) */
395
+ k?: number;
396
+ /** Filter expression */
397
+ filter?: FilterInput;
398
+ /** Optional dense vector to combine with sparse for hybrid named search */
399
+ vector?: number[] | Float32Array;
400
+ /** Search quality preset */
401
+ quality?: SearchQuality;
402
+ }
379
403
  /** Search options */
380
404
  interface SearchOptions {
381
405
  /** Number of results to return (default: 10) */
@@ -386,6 +410,18 @@ interface SearchOptions {
386
410
  includeVectors?: boolean;
387
411
  /** Optional sparse vector for hybrid sparse+dense search */
388
412
  sparseVector?: SparseVector;
413
+ /**
414
+ * Named sparse index to combine with the dense query for **hybrid** search
415
+ * (when the collection has multiple sparse indexes). When omitted, the
416
+ * default sparse index is used.
417
+ *
418
+ * For a **pure sparse** query against a named index (no dense vector),
419
+ * call `db.sparseSearchNamed()` instead — see {@link SparseSearchNamedOptions}.
420
+ *
421
+ * **Backend support:** REST only. The WASM backend silently ignores this
422
+ * field and uses the collection's single sparse index regardless.
423
+ */
424
+ sparseIndexName?: string;
389
425
  /** Search quality preset (default: 'balanced'). */
390
426
  quality?: SearchQuality;
391
427
  }
@@ -1152,6 +1188,17 @@ interface IVelesDBBackend {
1152
1188
  traverseParallel(collection: string, request: TraverseParallelRequest): Promise<TraverseResponse>;
1153
1189
  /** Get the in-degree and out-degree of a node */
1154
1190
  getNodeDegree(collection: string, nodeId: number): Promise<DegreeResponse>;
1191
+ /**
1192
+ * Search a named sparse index (issue #380).
1193
+ *
1194
+ * Sends `sparse_vectors: { [indexName]: query }` and `sparse_index: indexName`
1195
+ * to the `/search` endpoint. When `options.vector` is provided, the request
1196
+ * also includes a dense vector for hybrid sparse+dense search against the
1197
+ * named index.
1198
+ *
1199
+ * WASM backend: not supported (throws `VelesDB-WASM-NOT-SUPPORTED`).
1200
+ */
1201
+ sparseSearchNamed(collection: string, query: SparseVector, indexName: string, options?: SparseSearchNamedOptions): Promise<SearchResult[]>;
1155
1202
  /** Train Product Quantization on a collection */
1156
1203
  trainPq(collection: string, options?: PqTrainOptions): Promise<string>;
1157
1204
  /** Stream-insert documents with backpressure support */
@@ -1322,6 +1369,13 @@ declare class VelesDB {
1322
1369
  filter?: FilterInput;
1323
1370
  }): Promise<SearchResult[]>;
1324
1371
  multiQuerySearch(collection: string, vectors: Array<number[] | Float32Array>, options?: MultiQuerySearchOptions): Promise<SearchResult[]>;
1372
+ /**
1373
+ * Pure sparse search against a named sparse index.
1374
+ *
1375
+ * @see {@link SparseSearchNamedOptions} for the full pure-sparse vs hybrid comparison.
1376
+ * @see {@link VelesDB.search} for dense + sparse hybrid against a named index.
1377
+ */
1378
+ sparseSearchNamed(collection: string, query: SparseVector, indexName: string, options?: SparseSearchNamedOptions): Promise<SearchResult[]>;
1325
1379
  query(collection: string, queryString: string, params?: Record<string, unknown>, options?: QueryOptions): Promise<QueryApiResponse>;
1326
1380
  queryExplain(queryString: string, params?: Record<string, unknown>, options?: {
1327
1381
  analyze?: boolean;
@@ -1454,16 +1508,9 @@ declare class WasmBackend implements IVelesDBBackend {
1454
1508
  getNodePayload(c: string, id: number): Promise<NodePayloadResponse>;
1455
1509
  upsertNodePayload(c: string, id: number, p: Record<string, unknown>): Promise<void>;
1456
1510
  graphSearch(c: string, r: GraphSearchRequest): Promise<GraphSearchResponse>;
1511
+ sparseSearchNamed(c: string, q: SparseVector, idx: string, o?: SparseSearchNamedOptions): Promise<SearchResult[]>;
1457
1512
  }
1458
1513
 
1459
- /**
1460
- * REST Backend for VelesDB
1461
- *
1462
- * Connects to VelesDB server via REST API.
1463
- * This is the composition root that delegates to focused backend modules.
1464
- * HTTP infrastructure lives in rest-http.ts.
1465
- */
1466
-
1467
1514
  /**
1468
1515
  * REST Backend
1469
1516
  *
@@ -1521,6 +1568,7 @@ declare class RestBackend implements IVelesDBBackend {
1521
1568
  id: number;
1522
1569
  score: number;
1523
1570
  }>>;
1571
+ sparseSearchNamed(c: string, q: SparseVector, idx: string, o?: SparseSearchNamedOptions): Promise<SearchResult[]>;
1524
1572
  query(c: string, q: string, p?: Record<string, unknown>, o?: QueryOptions): Promise<QueryApiResponse>;
1525
1573
  queryExplain(q: string, p?: Record<string, unknown>, o?: {
1526
1574
  analyze?: boolean;
@@ -1998,4 +2046,4 @@ type VelesErrorCode = (typeof VELES_ERROR_CODES)[number];
1998
2046
  */
1999
2047
  declare function parseVelesError(code: string | null | undefined, message: string): VelesError;
2000
2048
 
2001
- export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };
2049
+ export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseSearchNamedOptions, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };
package/dist/index.d.ts CHANGED
@@ -376,6 +376,30 @@ declare const f: {
376
376
  * @packageDocumentation
377
377
  */
378
378
 
379
+ /**
380
+ * Options for `db.sparseSearchNamed()` — **pure sparse** query against a
381
+ * named sparse index (issue #380).
382
+ *
383
+ * Use this when you have only a sparse vector and want to query a specific
384
+ * named sparse index directly. The query carries no dense component.
385
+ *
386
+ * For **dense + sparse hybrid** against a named index, use
387
+ * `db.search(..., { sparseVector, sparseIndexName })` instead
388
+ * (see {@link SearchOptions.sparseIndexName}).
389
+ *
390
+ * **Backend support:** REST only. The WASM backend has no concept of named
391
+ * sparse indexes; this method throws `wasmNotSupported` on WASM.
392
+ */
393
+ interface SparseSearchNamedOptions {
394
+ /** Number of results to return (default: 10) */
395
+ k?: number;
396
+ /** Filter expression */
397
+ filter?: FilterInput;
398
+ /** Optional dense vector to combine with sparse for hybrid named search */
399
+ vector?: number[] | Float32Array;
400
+ /** Search quality preset */
401
+ quality?: SearchQuality;
402
+ }
379
403
  /** Search options */
380
404
  interface SearchOptions {
381
405
  /** Number of results to return (default: 10) */
@@ -386,6 +410,18 @@ interface SearchOptions {
386
410
  includeVectors?: boolean;
387
411
  /** Optional sparse vector for hybrid sparse+dense search */
388
412
  sparseVector?: SparseVector;
413
+ /**
414
+ * Named sparse index to combine with the dense query for **hybrid** search
415
+ * (when the collection has multiple sparse indexes). When omitted, the
416
+ * default sparse index is used.
417
+ *
418
+ * For a **pure sparse** query against a named index (no dense vector),
419
+ * call `db.sparseSearchNamed()` instead — see {@link SparseSearchNamedOptions}.
420
+ *
421
+ * **Backend support:** REST only. The WASM backend silently ignores this
422
+ * field and uses the collection's single sparse index regardless.
423
+ */
424
+ sparseIndexName?: string;
389
425
  /** Search quality preset (default: 'balanced'). */
390
426
  quality?: SearchQuality;
391
427
  }
@@ -1152,6 +1188,17 @@ interface IVelesDBBackend {
1152
1188
  traverseParallel(collection: string, request: TraverseParallelRequest): Promise<TraverseResponse>;
1153
1189
  /** Get the in-degree and out-degree of a node */
1154
1190
  getNodeDegree(collection: string, nodeId: number): Promise<DegreeResponse>;
1191
+ /**
1192
+ * Search a named sparse index (issue #380).
1193
+ *
1194
+ * Sends `sparse_vectors: { [indexName]: query }` and `sparse_index: indexName`
1195
+ * to the `/search` endpoint. When `options.vector` is provided, the request
1196
+ * also includes a dense vector for hybrid sparse+dense search against the
1197
+ * named index.
1198
+ *
1199
+ * WASM backend: not supported (throws `VelesDB-WASM-NOT-SUPPORTED`).
1200
+ */
1201
+ sparseSearchNamed(collection: string, query: SparseVector, indexName: string, options?: SparseSearchNamedOptions): Promise<SearchResult[]>;
1155
1202
  /** Train Product Quantization on a collection */
1156
1203
  trainPq(collection: string, options?: PqTrainOptions): Promise<string>;
1157
1204
  /** Stream-insert documents with backpressure support */
@@ -1322,6 +1369,13 @@ declare class VelesDB {
1322
1369
  filter?: FilterInput;
1323
1370
  }): Promise<SearchResult[]>;
1324
1371
  multiQuerySearch(collection: string, vectors: Array<number[] | Float32Array>, options?: MultiQuerySearchOptions): Promise<SearchResult[]>;
1372
+ /**
1373
+ * Pure sparse search against a named sparse index.
1374
+ *
1375
+ * @see {@link SparseSearchNamedOptions} for the full pure-sparse vs hybrid comparison.
1376
+ * @see {@link VelesDB.search} for dense + sparse hybrid against a named index.
1377
+ */
1378
+ sparseSearchNamed(collection: string, query: SparseVector, indexName: string, options?: SparseSearchNamedOptions): Promise<SearchResult[]>;
1325
1379
  query(collection: string, queryString: string, params?: Record<string, unknown>, options?: QueryOptions): Promise<QueryApiResponse>;
1326
1380
  queryExplain(queryString: string, params?: Record<string, unknown>, options?: {
1327
1381
  analyze?: boolean;
@@ -1454,16 +1508,9 @@ declare class WasmBackend implements IVelesDBBackend {
1454
1508
  getNodePayload(c: string, id: number): Promise<NodePayloadResponse>;
1455
1509
  upsertNodePayload(c: string, id: number, p: Record<string, unknown>): Promise<void>;
1456
1510
  graphSearch(c: string, r: GraphSearchRequest): Promise<GraphSearchResponse>;
1511
+ sparseSearchNamed(c: string, q: SparseVector, idx: string, o?: SparseSearchNamedOptions): Promise<SearchResult[]>;
1457
1512
  }
1458
1513
 
1459
- /**
1460
- * REST Backend for VelesDB
1461
- *
1462
- * Connects to VelesDB server via REST API.
1463
- * This is the composition root that delegates to focused backend modules.
1464
- * HTTP infrastructure lives in rest-http.ts.
1465
- */
1466
-
1467
1514
  /**
1468
1515
  * REST Backend
1469
1516
  *
@@ -1521,6 +1568,7 @@ declare class RestBackend implements IVelesDBBackend {
1521
1568
  id: number;
1522
1569
  score: number;
1523
1570
  }>>;
1571
+ sparseSearchNamed(c: string, q: SparseVector, idx: string, o?: SparseSearchNamedOptions): Promise<SearchResult[]>;
1524
1572
  query(c: string, q: string, p?: Record<string, unknown>, o?: QueryOptions): Promise<QueryApiResponse>;
1525
1573
  queryExplain(q: string, p?: Record<string, unknown>, o?: {
1526
1574
  analyze?: boolean;
@@ -1998,4 +2046,4 @@ type VelesErrorCode = (typeof VELES_ERROR_CODES)[number];
1998
2046
  */
1999
2047
  declare function parseVelesError(code: string | null | undefined, message: string): VelesError;
2000
2048
 
2001
- export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };
2049
+ export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseSearchNamedOptions, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };
package/dist/index.js CHANGED
@@ -957,6 +957,9 @@ async function wasmMatchProceduralPatterns(_collection, _embedding, _k) {
957
957
  }
958
958
 
959
959
  // src/backends/wasm-wave4-stubs.ts
960
+ function wasmSparseSearchNamed(_c, _q, _idx, _o) {
961
+ return Promise.resolve(wasmNotSupported("Named sparse index search"));
962
+ }
960
963
  function wasmRebuildIndex(_c) {
961
964
  return Promise.resolve(wasmNotSupported("Index rebuild"));
962
965
  }
@@ -1404,6 +1407,10 @@ var WasmBackend = class {
1404
1407
  this.ensureInitialized();
1405
1408
  return wasmGraphSearch(c, r);
1406
1409
  }
1410
+ async sparseSearchNamed(c, q, idx, o) {
1411
+ this.ensureInitialized();
1412
+ return wasmSparseSearchNamed(c, q, idx, o);
1413
+ }
1407
1414
  };
1408
1415
 
1409
1416
  // src/backends/crud-backend.ts
@@ -1977,6 +1984,9 @@ async function search(transport, collection, query3, options) {
1977
1984
  if (options?.sparseVector) {
1978
1985
  body.sparse_vector = transport.sparseToRest(options.sparseVector);
1979
1986
  }
1987
+ if (options?.sparseIndexName) {
1988
+ body.sparse_index = options.sparseIndexName;
1989
+ }
1980
1990
  const response = await transport.requestJson(
1981
1991
  "POST",
1982
1992
  `${collectionPath(collection)}/search`,
@@ -2042,12 +2052,33 @@ async function multiQuerySearch(transport, collection, vectors, options) {
2042
2052
  avg_weight: options?.fusionParams?.avgWeight,
2043
2053
  max_weight: options?.fusionParams?.maxWeight,
2044
2054
  hit_weight: options?.fusionParams?.hitWeight,
2055
+ dense_weight: options?.fusionParams?.denseWeight,
2056
+ sparse_weight: options?.fusionParams?.sparseWeight,
2045
2057
  filter: options?.filter
2046
2058
  }
2047
2059
  );
2048
2060
  throwOnError(response, `Collection '${collection}'`);
2049
2061
  return response.data?.results ?? [];
2050
2062
  }
2063
+ async function sparseSearchNamed(transport, collection, query3, indexName, options) {
2064
+ const body = {
2065
+ sparse_vectors: { [indexName]: transport.sparseToRest(query3) },
2066
+ sparse_index: indexName,
2067
+ top_k: options?.k ?? 10,
2068
+ filter: options?.filter,
2069
+ ...searchQualityToMode(options?.quality)
2070
+ };
2071
+ if (options?.vector) {
2072
+ body.vector = Array.from(options.vector);
2073
+ }
2074
+ const response = await transport.requestJson(
2075
+ "POST",
2076
+ `${collectionPath(collection)}/search`,
2077
+ body
2078
+ );
2079
+ throwOnError(response, `Collection '${collection}'`);
2080
+ return response.data?.results ?? [];
2081
+ }
2051
2082
  async function searchIds(transport, collection, query3, options) {
2052
2083
  const queryVector = toNumberArray(query3);
2053
2084
  const response = await transport.requestJson(
@@ -2735,6 +2766,10 @@ var RestBackend = class {
2735
2766
  this.ensureInitialized();
2736
2767
  return searchIds(buildSearchTransport(this.httpConfig), c, q, o);
2737
2768
  }
2769
+ async sparseSearchNamed(c, q, idx, o) {
2770
+ this.ensureInitialized();
2771
+ return sparseSearchNamed(buildSearchTransport(this.httpConfig), c, q, idx, o);
2772
+ }
2738
2773
  // Query
2739
2774
  async query(c, q, p, o) {
2740
2775
  this.ensureInitialized();
@@ -2941,6 +2976,11 @@ function hybridSearch2(backend, collection, vector, textQuery, options) {
2941
2976
  requireNonEmptyString(textQuery, "Text query");
2942
2977
  return backend.hybridSearch(collection, vector, textQuery, options);
2943
2978
  }
2979
+ function sparseSearchNamed2(backend, collection, query3, indexName, options) {
2980
+ requireNonEmptyString(collection, "Collection name");
2981
+ requireNonEmptyString(indexName, "Index name");
2982
+ return backend.sparseSearchNamed(collection, query3, indexName, options);
2983
+ }
2944
2984
  function multiQuerySearch2(backend, collection, vectors, options) {
2945
2985
  if (!Array.isArray(vectors) || vectors.length === 0) {
2946
2986
  throw new ValidationError("Vectors must be a non-empty array");
@@ -3217,6 +3257,16 @@ var VelesDB = class {
3217
3257
  this.ensureInitialized();
3218
3258
  return multiQuerySearch2(this.backend, collection, vectors, options);
3219
3259
  }
3260
+ /**
3261
+ * Pure sparse search against a named sparse index.
3262
+ *
3263
+ * @see {@link SparseSearchNamedOptions} for the full pure-sparse vs hybrid comparison.
3264
+ * @see {@link VelesDB.search} for dense + sparse hybrid against a named index.
3265
+ */
3266
+ async sparseSearchNamed(collection, query3, indexName, options) {
3267
+ this.ensureInitialized();
3268
+ return sparseSearchNamed2(this.backend, collection, query3, indexName, options);
3269
+ }
3220
3270
  async query(collection, queryString, params, options) {
3221
3271
  this.ensureInitialized();
3222
3272
  return query2(this.backend, collection, queryString, params, options);
package/dist/index.mjs CHANGED
@@ -819,6 +819,9 @@ async function wasmMatchProceduralPatterns(_collection, _embedding, _k) {
819
819
  }
820
820
 
821
821
  // src/backends/wasm-wave4-stubs.ts
822
+ function wasmSparseSearchNamed(_c, _q, _idx, _o) {
823
+ return Promise.resolve(wasmNotSupported("Named sparse index search"));
824
+ }
822
825
  function wasmRebuildIndex(_c) {
823
826
  return Promise.resolve(wasmNotSupported("Index rebuild"));
824
827
  }
@@ -1266,6 +1269,10 @@ var WasmBackend = class {
1266
1269
  this.ensureInitialized();
1267
1270
  return wasmGraphSearch(c, r);
1268
1271
  }
1272
+ async sparseSearchNamed(c, q, idx, o) {
1273
+ this.ensureInitialized();
1274
+ return wasmSparseSearchNamed(c, q, idx, o);
1275
+ }
1269
1276
  };
1270
1277
 
1271
1278
  // src/backends/crud-backend.ts
@@ -1839,6 +1846,9 @@ async function search(transport, collection, query3, options) {
1839
1846
  if (options?.sparseVector) {
1840
1847
  body.sparse_vector = transport.sparseToRest(options.sparseVector);
1841
1848
  }
1849
+ if (options?.sparseIndexName) {
1850
+ body.sparse_index = options.sparseIndexName;
1851
+ }
1842
1852
  const response = await transport.requestJson(
1843
1853
  "POST",
1844
1854
  `${collectionPath(collection)}/search`,
@@ -1904,12 +1914,33 @@ async function multiQuerySearch(transport, collection, vectors, options) {
1904
1914
  avg_weight: options?.fusionParams?.avgWeight,
1905
1915
  max_weight: options?.fusionParams?.maxWeight,
1906
1916
  hit_weight: options?.fusionParams?.hitWeight,
1917
+ dense_weight: options?.fusionParams?.denseWeight,
1918
+ sparse_weight: options?.fusionParams?.sparseWeight,
1907
1919
  filter: options?.filter
1908
1920
  }
1909
1921
  );
1910
1922
  throwOnError(response, `Collection '${collection}'`);
1911
1923
  return response.data?.results ?? [];
1912
1924
  }
1925
+ async function sparseSearchNamed(transport, collection, query3, indexName, options) {
1926
+ const body = {
1927
+ sparse_vectors: { [indexName]: transport.sparseToRest(query3) },
1928
+ sparse_index: indexName,
1929
+ top_k: options?.k ?? 10,
1930
+ filter: options?.filter,
1931
+ ...searchQualityToMode(options?.quality)
1932
+ };
1933
+ if (options?.vector) {
1934
+ body.vector = Array.from(options.vector);
1935
+ }
1936
+ const response = await transport.requestJson(
1937
+ "POST",
1938
+ `${collectionPath(collection)}/search`,
1939
+ body
1940
+ );
1941
+ throwOnError(response, `Collection '${collection}'`);
1942
+ return response.data?.results ?? [];
1943
+ }
1913
1944
  async function searchIds(transport, collection, query3, options) {
1914
1945
  const queryVector = toNumberArray(query3);
1915
1946
  const response = await transport.requestJson(
@@ -2597,6 +2628,10 @@ var RestBackend = class {
2597
2628
  this.ensureInitialized();
2598
2629
  return searchIds(buildSearchTransport(this.httpConfig), c, q, o);
2599
2630
  }
2631
+ async sparseSearchNamed(c, q, idx, o) {
2632
+ this.ensureInitialized();
2633
+ return sparseSearchNamed(buildSearchTransport(this.httpConfig), c, q, idx, o);
2634
+ }
2600
2635
  // Query
2601
2636
  async query(c, q, p, o) {
2602
2637
  this.ensureInitialized();
@@ -2803,6 +2838,11 @@ function hybridSearch2(backend, collection, vector, textQuery, options) {
2803
2838
  requireNonEmptyString(textQuery, "Text query");
2804
2839
  return backend.hybridSearch(collection, vector, textQuery, options);
2805
2840
  }
2841
+ function sparseSearchNamed2(backend, collection, query3, indexName, options) {
2842
+ requireNonEmptyString(collection, "Collection name");
2843
+ requireNonEmptyString(indexName, "Index name");
2844
+ return backend.sparseSearchNamed(collection, query3, indexName, options);
2845
+ }
2806
2846
  function multiQuerySearch2(backend, collection, vectors, options) {
2807
2847
  if (!Array.isArray(vectors) || vectors.length === 0) {
2808
2848
  throw new ValidationError("Vectors must be a non-empty array");
@@ -3079,6 +3119,16 @@ var VelesDB = class {
3079
3119
  this.ensureInitialized();
3080
3120
  return multiQuerySearch2(this.backend, collection, vectors, options);
3081
3121
  }
3122
+ /**
3123
+ * Pure sparse search against a named sparse index.
3124
+ *
3125
+ * @see {@link SparseSearchNamedOptions} for the full pure-sparse vs hybrid comparison.
3126
+ * @see {@link VelesDB.search} for dense + sparse hybrid against a named index.
3127
+ */
3128
+ async sparseSearchNamed(collection, query3, indexName, options) {
3129
+ this.ensureInitialized();
3130
+ return sparseSearchNamed2(this.backend, collection, query3, indexName, options);
3131
+ }
3082
3132
  async query(collection, queryString, params, options) {
3083
3133
  this.ensureInitialized();
3084
3134
  return query2(this.backend, collection, queryString, params, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wiscale/velesdb-sdk",
3
- "version": "1.14.4",
3
+ "version": "1.15.0",
4
4
  "description": "VelesDB TypeScript SDK: The Local Vector Database for AI & RAG. Microsecond semantic search in Browser & Node.js.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -22,8 +22,8 @@
22
22
  "test": "vitest run",
23
23
  "test:watch": "vitest",
24
24
  "test:coverage": "vitest run --coverage",
25
- "lint": "eslint src --ext .ts",
26
- "lint:fix": "eslint src --ext .ts --fix",
25
+ "lint": "eslint src",
26
+ "lint:fix": "eslint src --fix",
27
27
  "format": "prettier --write src",
28
28
  "typecheck": "tsc --noEmit",
29
29
  "prepublishOnly": "npm run build"
@@ -54,15 +54,17 @@
54
54
  "url": "https://github.com/cyberlife-coder/VelesDB/issues"
55
55
  },
56
56
  "devDependencies": {
57
+ "@eslint/js": "^9.0.0",
57
58
  "@types/node": "^25.6.0",
58
- "@typescript-eslint/eslint-plugin": "^6.0.0",
59
- "@typescript-eslint/parser": "^6.0.0",
59
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
60
+ "@typescript-eslint/parser": "^8.0.0",
60
61
  "@vitest/coverage-v8": "^4.0.16",
61
- "eslint": "^8.0.0",
62
- "eslint-config-prettier": "^9.0.0",
62
+ "eslint": "^10.3.0",
63
+ "eslint-config-prettier": "^10.1.8",
63
64
  "prettier": "^3.0.0",
64
65
  "tsup": "^8.0.0",
65
- "typescript": "^5.3.0",
66
+ "typescript": "^6.0.3",
67
+ "typescript-eslint": "^8.0.0",
66
68
  "vitest": "^4.0.16"
67
69
  },
68
70
  "dependencies": {