Skip to main content
Version: V1.2.0

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:

FieldTypeDefaultDescription and constraints
dimensionnumber384Vector dimension, 1–4096
distancestring"cosine"Distance metric: l2, cosine, inner_product
typestring"hnsw"Index type: hnsw, hnsw_sq, hnsw_bq
libstring"vsag"Implementation library: vsag
Mnumber16Max connections, 5–128
ef_constructionnumber200Build-time search range, 5–1000
ef_searchnumber64Query-time search range, 1–1000
extra_info_max_sizenumber0Max extra info size, 0–16384
refine_knumber4.0Refine search parameter, 1.0–1000.0 (hnsw_bq only)
refine_typestring"sq8"Refine type: sq8, fp32 (hnsw_bq only)
bq_bits_querynumber32Quantized query bits: 0, 4, or 32 (hnsw_bq only)
bq_use_fhtbooleantrueWhether to use FHT (hnsw_bq only)

VectorIndexConfig combines HNSW with an embedding function:

  • hnsw: HNSWConfiguration or None (default HNSW).
  • embedding_function: EmbeddingFunction; if omitted, DefaultEmbeddingFunction() is used.

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,
},
}),
})