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

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

HGraph

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": 128,
    "dtype": "float32",
    "metric_type": "l2",
    "index_param": {
        "base_quantization_type": "fp32",
        "max_degree": 32,
        "ef_construction": 400
    }
}
)";
auto index = vsag::Factory::CreateIndex("hgraph", params).value();

HGraph with SQ8 quantization

Switch base_quantization_type to sq8 to store base vectors as 8-bit scalar-quantized codes (roughly a 4× reduction versus fp32) with minimal recall impact; other quantization types (fp16, bf16, pq, …) are selected the same way.

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

See Index Parameters for the full reference.