FlatIndex<T>
Models & Types · AiDotNet.RetrievalAugmentedGeneration.VectorSearch.Indexes
Flat index that performs exact brute-force similarity search.
Implements: IVectorIndex<T>
How It Works
This is the simplest and most accurate index type, comparing the query against every vector in the index. It guarantees exact nearest neighbors but has O(n) search complexity where n is the number of vectors. Best for small datasets (< 10K vectors) where accuracy is critical.
Constructors
| Constructor | Summary |
|---|---|
FlatIndex(ISimilarityMetric<T> metric) |
Initializes a new instance of the FlatIndex class. |
Properties
| Property | Summary |
|---|---|
int Count { get; } |
Methods
| Method | Summary |
|---|---|
List<ValueTuple<string, T>> Search(Vector<T> query, int k) |
|
bool Remove(string id) |
|
void Add(string id, Vector<T> vector) |
|
void AddBatch(Dictionary<string, Vector<T>> vectors) |
|
void Clear() |