Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Creating an Index

All VSAG indexes are built through vsag::Factory::CreateIndex(name, build_params_json). The name selects the implementation; build_params_json configures dimension, metric, and index-specific options.

Supported Index Types

NameDescriptionPageExample
hgraphImproved graph index with richer quantization optionsHGraphexamples/cpp/103_index_hgraph.cpp
ivfInverted file with quantizationIVFexamples/cpp/106_index_ivf.cpp
sindiSparse-vector index (e.g. BM25, SPLADE)SINDIexamples/cpp/109_index_sindi.cpp
pyramidMulti-tenant / tag-partitioned graph indexPyramidexamples/cpp/107_index_pyramid.cpp
brute_forceExact exhaustive search; useful as baselineexamples/cpp/105_index_brute_force.cpp
hnswClassic HNSW graph index (deprecated — prefer hgraph)examples/cpp/101_index_hnsw.cpp
diskannMemory-disk hybrid (deprecated — prefer ivf)examples/cpp/102_index_diskann.cpp

Common Top-Level Fields

FieldValuesNotes
dimpositive integerFixed after build
dtypefloat32 / fp16 / bf16 / int8Public API currently uses float32
metric_typel2 / ip / cosineMust match at query time

Examples

HNSW

std::string params = R"(
{
    "dim": 128,
    "dtype": "float32",
    "metric_type": "l2",
    "hnsw": {
        "max_degree": 32,
        "ef_construction": 400
    }
}
)";
auto index = vsag::Factory::CreateIndex("hnsw", params).value();

HGraph with FP16 quantization

HGraph uses index_param as the build-time sub-object (hgraph is reserved for search-time parameters like ef_search). See examples/cpp/103_index_hgraph.cpp.

std::string params = R"(
{
    "dim": 768,
    "dtype": "float32",
    "metric_type": "ip",
    "index_param": {
        "base_quantization_type": "fp16",
        "max_degree": 32,
        "ef_construction": 400
    }
}
)";
auto index = vsag::Factory::CreateIndex("hgraph", params).value();

See Index Parameters for the full reference.