Dense vector index
In modern big data and AI workloads, vector data is widely used for high-dimensional features such as images, text, and audio. Vector data often has these characteristics:
- High dimensionality: Each vector can have hundreds to thousands of dimensions.
- Sparsity: Many vectors are mostly zeros (sparse vectors).
- Similarity queries: Applications often need approximate nearest neighbor search (ANNS).
To handle this vector data efficiently, seekdb-js exposes HNSW (Hierarchical Navigable Small World) vector index settings (HNSWConfiguration) to speed up similarity search.
Use cases
Vector indexes fit scenarios such as:
- Recommendation systems: Match users or items using vector similarity.
- Image retrieval: Find similar images quickly via feature vectors.
- Semantic text search: Match meaning using word or sentence vectors.
- Bioinformatics: Work with high-dimensional vectors for genes or proteins.
- Anomaly detection: Spot unusual patterns via vector similarity.
Field reference
HNSWConfiguration configures a dense vector index (HNSW). Fields:
| Field | Type | Default | Description and constraints |
|---|---|---|---|
| dimension | number | 384 | Vector dimension, 1–4096 |
| distance | string | "cosine" | Distance metric: l2, cosine, inner_product |
| type | string | "hnsw" | Index type: hnsw, hnsw_sq, hnsw_bq |
| lib | string | "vsag" | Implementation library: vsag |
| syncMode | string | "async" | HNSW synchronous/asynchronous maintenance: "immediate" / "async". Semantics match SQL sync_mode. Supported for hnsw, hnsw_sq, and hnsw_bq. |
| M | number | 16 | Max connections, 5–128 |
| ef_construction | number | 200 | Build-time search range, 5–1000 |
| ef_search | number | 64 | Query-time search range, 1–1000 |
| extra_info_max_size | number | 0 | Max extra info size, 0–16384 |
| refine_k | number | 4.0 | Refine search parameter, 1.0–1000.0 (hnsw_bq only) |
| refine_type | string | "sq8" | Refine type: sq8, fp32 (hnsw_bq only) |
| bq_bits_query | number | 32 | Quantized query bits: 0, 4, or 32 (hnsw_bq only) |
| bq_use_fht | boolean | true | Whether to use FHT (hnsw_bq only) |
VectorIndexConfig combines HNSW with an embedding function:
hnsw:HNSWConfigurationorNone(default HNSW).embedding_function:EmbeddingFunction; if omitted,DefaultEmbeddingFunction()is used.
Asynchronous maintenance and refresh_index
When hnsw.syncMode is "async" (the server and embedded default in seekdb V1.3.0 and later), writes can return before the index catches up and approximate search is eventually consistent. To get approximate hits as soon as possible after a write, call await collection.refresh_index() on the Collection. See refresh_index. You can also run SQL CALL dbms_index_manager.refresh();. See REFRESH (DBMS_INDEX_MANAGER).
Usage
To use a dense vector index in seekdb-js, configure it through Schema when you create a collection. If you do not set any schema fields, the collection defaults to an HNSW dense vector index.
Prerequisites
Install seekdb-js V1.2.0 or later.
npm install seekdb
Usage example
Creating a schema with the default index
When no schema is specified, SeekDB creates the collection with the default full-text index and vector index:
import { SeekdbClient, Schema } from "seekdb";
const client = new SeekdbClient({
host: "127.0.0.1",
port: 2881,
database: "test",
user: "root",
password: "",
// for OceanBase, set tenant to "sys"
// tenant: "sys",
});
// Explicitly create with defaults
const collection = await client.getOrCreateCollection({
name: "my_collection",
});
The default configuration is:
new Schema({
fulltextIndex: new FullTextIndexConfig({
analyzer: "ik",
}),
vectorIndex: new VectorIndexConfig({
hnsw: {
distance: "cosine",
type: "hnsw",
lib: "vsag",
dimension: 384,
},
}),
})