fix(search): Refactor search tests to use unified search API and update text index type casting

This commit is contained in:
2025-04-18 14:56:11 +00:00
parent 1a359d355a
commit e325b42906
4 changed files with 54 additions and 17 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartdata',
version: '5.9.0',
version: '5.9.1',
description: 'An advanced library for NoSQL data organization and manipulation using TypeScript with support for MongoDB, data validation, collections, and custom data types.'
}

View File

@ -158,9 +158,11 @@ export class SmartdataCollection<T> {
// Auto-create a compound text index on all searchable fields
const searchableFields = getSearchableFields(this.collectionName);
if (searchableFields.length > 0 && !this.textIndexCreated) {
const indexSpec: { [key: string]: string } = {};
// Build a compound text index spec
const indexSpec: Record<string, 'text'> = {};
searchableFields.forEach(f => { indexSpec[f] = 'text'; });
await this.mongoDbCollection.createIndex(indexSpec, { name: 'smartdata_text_index' });
// Cast to any to satisfy TypeScript IndexSpecification typing
await this.mongoDbCollection.createIndex(indexSpec as any, { name: 'smartdata_text_index' });
this.textIndexCreated = true;
}
}