@andrejs1979/document
Version:
MongoDB-compatible document database for NoSQL
85 lines • 2.76 kB
TypeScript
/**
* NoSQL - Document Index Manager
* Advanced indexing system for fast document queries
*/
import { IndexSpec, IndexInfo, QueryFilter, DocumentDatabaseConfig } from '../types';
/**
* Smart index manager with auto-indexing capabilities
*/
export declare class DocumentIndexManager {
private d1;
private kvStore?;
private config;
private indexCache;
private queryPatterns;
private fieldUsage;
constructor(config: DocumentDatabaseConfig);
/**
* Create a new index
*/
createIndex(database: string, collection: string, indexSpec: IndexSpec): Promise<void>;
/**
* Drop an existing index
*/
dropIndex(database: string, collection: string, indexName: string): Promise<void>;
/**
* List all indexes for a collection
*/
listIndexes(database: string, collection: string): Promise<IndexInfo[]>;
/**
* Get index recommendations based on query patterns
*/
getIndexRecommendations(database: string, collection: string): Promise<{
recommended: IndexSpec[];
reasons: string[];
priority: 'high' | 'medium' | 'low';
}>;
/**
* Auto-create indexes based on query patterns
*/
autoCreateIndexes(database: string, collection: string): Promise<void>;
/**
* Track query pattern for auto-indexing
*/
trackQueryPattern(database: string, collection: string, filter: QueryFilter, options?: any): void;
/**
* Get optimal index for a query
*/
getOptimalIndex(database: string, collection: string, filter: QueryFilter, sort?: any): Promise<IndexInfo | null>;
/**
* Rebuild index (refresh statistics and optimize)
*/
rebuildIndex(database: string, collection: string, indexName: string): Promise<void>;
/**
* Get index usage statistics
*/
getIndexStats(database: string, collection: string): Promise<{
totalIndexes: number;
totalSize: number;
usageStats: Record<string, number>;
recommendations: string[];
}>;
private createIndexByType;
private createBTreeIndex;
private createTextIndex;
private createVectorIndex;
private createGeospatialIndex;
private dropIndexByType;
private generateIndexName;
private indexExists;
private storeIndexMetadata;
private removeIndexMetadata;
private getIndexInfo;
private cacheIndexInfo;
private getIndexCacheKey;
private extractQueryFields;
private getIndexColumn;
private analyzeQueryPatterns;
private getFrequentlyUsedFields;
private getTextSearchFields;
private hasVectorOperations;
private hasEquivalentIndex;
private indexSpecsEqual;
private calculateIndexScore;
}
//# sourceMappingURL=index-manager.d.ts.map