Skip to content

feat(nodejs): add IVF_HNSW_FLAT vector index support#3367

Draft
shenganzhang wants to merge 2 commits into
lancedb:mainfrom
shenganzhang:feat/nodejs-ivf-hnsw-flat
Draft

feat(nodejs): add IVF_HNSW_FLAT vector index support#3367
shenganzhang wants to merge 2 commits into
lancedb:mainfrom
shenganzhang:feat/nodejs-ivf-hnsw-flat

Conversation

@shenganzhang
Copy link
Copy Markdown
Contributor

@shenganzhang shenganzhang commented May 10, 2026

Summary

Mirror the Python IVF_HNSW_FLAT support added in #3366 on the Node.js / TypeScript side, so users of all bindings can build IVF + per-partition HNSW indexes without quantisation.

  • napi (nodejs/src/index.rs): new Index.hnsw_flat factory wrapping IvfHnswFlatIndexBuilder, parallel to the existing hnsw_sq / hnsw_pq factories.
  • ts (nodejs/lancedb/indices.ts): new HnswFlatOptions interface and Index.hnswFlat(...) static method, re-exported from nodejs/lancedb/index.ts.
  • test (nodejs/__test__/table.test.ts): cover index creation through Index.hnswFlat({ numPartitions }).

Refs #3331

Stacked on #3366 — that PR introduces the IvfHnswFlatIndexBuilder this branch depends on. The current diff therefore contains both commits; once #3366 lands I will rebase this branch onto main so only the Node.js commit remains. Keeping this in draft until then.

Test plan

  • `cd nodejs && npm run build && npm run lint && npm test test/table.test.ts`

shenganzhang and others added 2 commits May 10, 2026 15:20
Expose the `IVF_HNSW_FLAT` index (IVF partitions with an HNSW graph per
partition, no quantization) through the Rust core and Python SDK. Until
now this index type was documented but not actually wired up in the
lancedb Python wrapper, even though `pylance` accepts it.

Rust core changes:
* Add `Index::IvfHnswFlat` / `IndexType::IvfHnswFlat` variants and the
  corresponding `IvfHnswFlatIndexBuilder` (modelled on the existing
  `IvfHnswSqIndexBuilder`), with display/parse round-trips.
* Build the Lance index params via the existing
  `VectorIndexParams::ivf_hnsw(...)` helper for consistency with the
  other IVF_HNSW_* variants.
* Forward the new variant in `RemoteTable::create_index` and cover both
  the default-config and customised-config serialisation in the
  parametrised remote test.

Python binding changes:
* New `HnswFlat` dataclass + `IvfHnswFlat` backwards-compat alias.
* PyO3 `extract_index_params` recognises the `HnswFlat` config class.
* `LanceTable.create_index(index_type="IVF_HNSW_FLAT", ...)` and the
  sync `RemoteTable.create_index` both dispatch to the new config.
* `IndexStatistics.index_type` Literal and `_lancedb.pyi` stubs cover
  the new type so pyright stays happy.
* Async + sync integration tests and a dispatcher unit test mirror the
  pattern used for `IVF_HNSW_SQ`.

A matching Node.js / TypeScript binding will land in a follow-up PR.

Closes lancedb#3331
Mirror the Python `IVF_HNSW_FLAT` support added in the previous commit
on the Node.js / TypeScript side, so users of all bindings can build
IVF + per-partition HNSW indexes without quantization.

* napi: new `Index.hnsw_flat` factory wrapping
  `IvfHnswFlatIndexBuilder`, parallel to the existing `hnsw_sq` and
  `hnsw_pq` factories.
* ts: new `HnswFlatOptions` interface and `Index.hnswFlat(...)` static
  method, re-exported from `lancedb/index.ts`.
* test: cover index creation through `Index.hnswFlat({ numPartitions })`
  in `__test__/table.test.ts`.

Refs lancedb#3331

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added enhancement New feature or request Python Python SDK Rust Rust related issues labels May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Python Python SDK Rust Rust related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant