diff --git a/data-access/seedwork/services-seedwork-cognitive-search-az/index.ts b/data-access/seedwork/services-seedwork-cognitive-search-az/index.ts index 2fea512e..7636c0a7 100644 --- a/data-access/seedwork/services-seedwork-cognitive-search-az/index.ts +++ b/data-access/seedwork/services-seedwork-cognitive-search-az/index.ts @@ -36,8 +36,8 @@ export class AzCognitiveSearch implements CognitiveSearchBase { } // check if index exists - async indexExists(indexName: string): Promise { - return this.searchClients.has(indexName); + indexExists(indexName: string): boolean { + return this.getSearchClient(indexName) !== undefined; } async createIndexIfNotExists(indexDefinition: SearchIndex): Promise { @@ -100,9 +100,4 @@ export class AzCognitiveSearch implements CognitiveSearchBase { throw new Error(`Failed to delete index ${indexName}: ${error.message}`); } } - - // async updateIndex(indexName: string) { - // const index = await this.client.getIndex(indexName); - // this.client.createOrUpdateIndex(index); - // } } diff --git a/data-access/seedwork/services-seedwork-cognitive-search-in-memory/index.ts b/data-access/seedwork/services-seedwork-cognitive-search-in-memory/index.ts index 32701e5c..eaa21f9c 100644 --- a/data-access/seedwork/services-seedwork-cognitive-search-in-memory/index.ts +++ b/data-access/seedwork/services-seedwork-cognitive-search-in-memory/index.ts @@ -1,5 +1,5 @@ -import { CognitiveSearchDomain } from "../../src/app/domain/infrastructure/cognitive-search/interfaces"; -import { BaseDocumentType, SearchIndex } from "./interfaces"; +import { CognitiveSearchDomain } from '../../src/app/domain/infrastructure/cognitive-search/interfaces'; +import { BaseDocumentType, SearchIndex } from './interfaces'; export interface IMemoryCognitiveSearchCollection { indexDocument(document: DocumentType): Promise; @@ -11,17 +11,15 @@ export interface IMemoryCognitiveSearch { deleteDocument(indexName: string, document: any): Promise; indexDocument(indexName: string, document: any): Promise; search(indexName: string, searchText: string, options?: any): Promise; - indexExists(indexName: string): Promise; + indexExists(indexName: string): boolean; logSearchCollectionIndexMap(): void; - } - export class MemoryCognitiveSearchCollection implements IMemoryCognitiveSearchCollection { private searchCollection: DocumentType[] = []; - constructor () {} - + constructor() {} + async indexDocument(document: DocumentType): Promise { const existingDocument = this.searchCollection.find((i) => i.id === document.id); if (existingDocument) { @@ -36,9 +34,7 @@ export class MemoryCognitiveSearchCollection>; private searchCollectionIndexDefinitionMap: Map; @@ -46,12 +42,9 @@ export class MemoryCognitiveSearch implements IMemoryCognitiveSearch, CognitiveS this.searchCollectionIndexMap = new Map>(); this.searchCollectionIndexDefinitionMap = new Map(); } - initializeSearchClients(): Promise { - throw new Error("Method not implemented."); - } - + deleteIndex(indexName: string): Promise { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.'); } async createIndexIfNotExists(indexDefinition: SearchIndex): Promise { @@ -90,9 +83,9 @@ export class MemoryCognitiveSearch implements IMemoryCognitiveSearch, CognitiveS for (const [key, value] of this.searchCollectionIndexMap.entries()) { console.log(`Index: ${key} | Documents: ${JSON.stringify(value)}`); } - } + } - async indexExists(indexName: string): Promise { + indexExists(indexName: string): boolean { return this.searchCollectionIndexMap.has(indexName); } -} \ No newline at end of file +} diff --git a/data-access/seedwork/services-seedwork-cognitive-search-interfaces/index.ts b/data-access/seedwork/services-seedwork-cognitive-search-interfaces/index.ts index 6ee71e8b..44301e3a 100644 --- a/data-access/seedwork/services-seedwork-cognitive-search-interfaces/index.ts +++ b/data-access/seedwork/services-seedwork-cognitive-search-interfaces/index.ts @@ -8,5 +8,5 @@ export interface CognitiveSearchBase { deleteDocument(indexName: string, document: any): Promise; indexDocument(indexName: string, document: any): Promise; deleteIndex(indexName: string): Promise; - indexExists(indexName: string): Promise; + indexExists(indexName: string): boolean; } \ No newline at end of file