Skip to main content
Adds or updates vector embeddings in the index.
void Upsert(Array2D<float>& vectors,
            const std::vector<uint64_t> ids,
            const std::vector<std::vector<uint8_t>> items = {});

Parameters

ParameterTypeDescription
vectorsArray2D<float>2D container with vector embeddings to index.
idsstd::vector<uint64_t>Unique identifiers for each vector.
itemsstd::vector<std::vector<uint8_t>>(Optional) Item contents in bytes.

Exceptions

  • Throws if vector dimensions are incompatible with the index configuration.
  • Throws if index was not created or loaded yet.
  • Throws if there is a mismatch between the number of vectors, ids or items.
  • Throws if the vectors could not be upserted.

Example Usage

// Assume Array2D<float> is properly defined and populated.
cyborg::Array2D<float> embeddings{/*...*/};
std::vector<uint64_t> ids = {1, 2, 3};

// Upsert without additional item data
index->Upsert(embeddings, ids);

// Upsert with associated items
std::vector<std::vector<uint8_t>> items = {
    {'a', 'b', 'c'}, {'d', 'e', 'f'}, {'g', 'h', 'i'}
};
index->Upsert(embeddings, ids, items);
I