export declare enum Space { Euclidean = 0, InnerProduct = 1, Cosine = 2 } export declare enum StorageDataType { Float8 = 16, Float32 = 32, E4M3 = 48 } export interface IndexOptions { space: Space; numDimensions: number; M?: number; efConstruction?: number; randomSeed?: number; maxElements?: number; storageDataType?: StorageDataType; } export interface LoadOptions { space?: Space; numDimensions?: number; storageDataType?: StorageDataType; } export interface QueryResult { neighbors: number[]; distances: number[]; } export interface QueryResults { neighbors: number[][]; distances: number[][]; } /** A nearest-neighbor search index containing vector data. * Think of a Voyager Index as a Map where you can * efficiently find the k nearest keys to a query vector. */ export declare class Index { private _index; constructor(options: IndexOptions); /** Add a single vector to the index * @param vector - The vector to add (array of numbers) * @param id - Optional ID to assign (auto-generated if not provided) * @returns The ID assigned to this vector */ addItem(vector: number[], id?: number): number; /** Add multiple vectors to the index simultaneously * @param vectors - Array of vectors to add * @param ids - Optional array of IDs (must match vectors length if palovided) * @param numThreads - Number of threads to use (-1 for auto) * @returns Array of IDs assigned to the vectors */ addItems(vectors: number[][], ids?: number[], numThreads?: number): number[]; /** Query the index for nearest neighbors of a single vector * @param vector - Vector to query * @param k - Number of neighbors to return (default: 1) * @param numThreads - Number of threads for parallel queries (-1 for auto) * @param queryEf - Search depth for this query (-1 to use default ef) * @returns Object containing neighbors and distances arrays */ query(vectors: number[], k?: number, numThreads?: number, queryEf?: number): QueryResult; /** Query the index for nearest neighbors of multiple vectors * @param vectors - Array of vectors to query * @param k - Number of neighbors to return (default: 1) * @param numThreads - Number of threads for parallel queries (-1 for auto) * @param queryEf - Search depth for this query (-1 to use default ef) * @returns Object containing arrays of neighbors and distances */ query(vectors: number[][], k?: number, numThreads?: number, queryEf?: number): QueryResults; /** Get the vector stored at the given ID * @param id - The ID to retrieve * @returns The vector as an array of numbers */ getVector(id: number): number[]; /** Get multiple vectors by their IDs * @param ids - Array of IDs to retrieve * @returns Array of vectors */ getVectors(ids: number[]): number[][]; /** Mark an ID as deleted (will not appear in query results) * @param id - The ID to mark as deleted */ markDeleted(id: number): void; /** Unmark an ID as deleted (will appear in query results again) * @param id - The ID to unmark */ unmarkDeleted(id: number): void; /** Resize the index to accommodate more elements * @param newSize - New maximum number of elements */ resize(newSize: number): void; /** Save the index to a file * @param filePath - Path where the index should be saved */ saveIndex(filePath: string): void; /** Load an index from a file * @param filePath - Path to the index file * @param options - Optional parameters for loading legacy indices * @returns A new Index instance */ static loadIndex(filePath: string, options?: LoadOptions): Index; /** Get the distance between two vectors * @param a - First vector * @param b - Second vector * @returns The distance between the vectors */ getDistance(a: number[], b: number[]): number; /** Serialize the index to a Buffer * @returns Buffer containing the serialized index */ toBuffer(): Buffer; /** Load an index from a Buffer * @param buffer - Buffer containing the serialized index * @param options - Optional parameters for loading legacy indices * @returns A new Index instance */ static fromBuffer(buffer: Buffer, options?: LoadOptions): Index; /** Check if an ID exists in the index * @param id - The ID to check * @returns True if the ID exists, false otherwise */ has(id: number): boolean; /** Get a string representation of the index * @returns String describing the index */ toString(): string; /** The Space used to calculate distances */ get space(): Space; /** The number of dimensions in each vector */ get numDimensions(): number; /** The M parameter (number of connections) */ get M(): number; /** The efConstruction parameter */ get efConstruction(): number; /** The maximum number of elements that can be stored */ get maxElements(): number; /** Set the maximum number of elements (resizes the index) */ set maxElements(value: number); /** The storage data type used by this index */ get storageDataType(): StorageDataType; /** The current number of elements in the index */ get numElements(): number; /** Array of all non-deleted IDs in the index */ get ids(): number[]; /** The default search depth for queries */ get ef(): number; /** Set the default search depth for queries */ set ef(value: number); /** The number of non-deleted vectors in the index. * This is an alias for the number of IDs in the index. */ get length(): number; } export declare const NativeSpace: any, NativeStorageDataType: any;