Skip to content

Embeddings embeddingindex getid

github-actions[bot] edited this page Aug 26, 2026 · 24 revisions

Development build. This page describes main, not a released package. The latest published Lodestar.Embeddings is 0.4.0 — read its documentation.

EmbeddingIndex.GetId

The id stored at a position, or null when that item has none.

public string GetId(int index)

Parametersindex is a position in [0, Count) — in practice a SearchResult.Index handed back by Search.

Returnsstring, the id given to Add, or null if that vector was added without one.

ExceptionsArgumentOutOfRangeException when index is negative or not less than Count. The message names the valid range.

Example — one vector with an id, one without.

using Lodestar.Embeddings.Search;

var index = new EmbeddingIndex(dimension: 2);
index.Add(new float[] { 1f, 0f }, "east");
index.Add(new float[] { 0f, 1f });

string named = index.GetId(0)!;  // => east
bool anonymous = index.GetId(1) is null;  // => True

Remarks — this is the step from a search hit to your own data, and it is a lookup rather than a field on the result for a reason SearchResult sets out: keeping references out of the scored array is what makes scoring and sorting cheap.

null means two different things and the type cannot tell them apart: the vector was added without an id, or it was added with an explicit null, which Add treats as the same thing. HasIds answers the coarser question of whether the index carries ids at all.

Ids survive a Save and Load round trip, which is what makes them worth storing: a reloaded index can name its documents without the original corpus being present.

Applies to — net10.0, netstandard2.0.

See alsoEmbeddingIndex.Add, EmbeddingIndex.Search, EmbeddingIndex.

Lodestar

Project

Clone this wiki locally