index_add: Add a Vector to the Index

View source: R/index.R

index_addR Documentation

Add a Vector to the Index

Description

Adds a vector with the given ID to the index, optionally with metadata.

Usage

index_add(index, id, vector, meta = NULL)

Arguments

index

An usearchlite_index object.

id

Integer. Unique identifier for the vector.

vector

Numeric vector of length equal to the index dimension.

meta

Optional list of metadata to associate with this vector.

Value

The index object (invisibly), for chaining.

Examples

tmp <- tempfile()
dir.create(tmp)
idx <- index_new(3L, tmp)
idx <- index_add(idx, 1L, c(1, 0, 0), meta = list(category = "a"))
unlink(tmp, recursive = TRUE)

usearchlite documentation built on Feb. 13, 2026, 1:06 a.m.