From aa91b946fa6864f0edb50a4a2c9b49cc03f8f881 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Tue, 25 Apr 2023 13:21:07 -0400 Subject: [PATCH] fix(server): use current schema for search/explore (#2331) --- .../src/repositories/typesense.repository.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/server/libs/infra/src/repositories/typesense.repository.ts b/server/libs/infra/src/repositories/typesense.repository.ts index d4682ee27f..c56cef053d 100644 --- a/server/libs/infra/src/repositories/typesense.repository.ts +++ b/server/libs/infra/src/repositories/typesense.repository.ts @@ -132,15 +132,13 @@ export class TypesenseRepository implements ISearchRepository { } async explore(userId: string): Promise[]> { - const alias = await this.client.aliases(SearchCollection.ASSETS).retrieve(); - const common = { q: '*', filter_by: this.buildFilterBy('ownerId', userId, true), per_page: 100, }; - const asset$ = this.client.collections(alias.collection_name).documents(); + const asset$ = this.client.collections(assetSchema.name).documents(); const { facet_counts: facets } = await asset$.search({ ...common, @@ -208,10 +206,8 @@ export class TypesenseRepository implements ISearchRepository { } async searchAlbums(query: string, filters: SearchFilter): Promise> { - const alias = await this.client.aliases(SearchCollection.ALBUMS).retrieve(); - const results = await this.client - .collections(alias.collection_name) + .collections(albumSchema.name) .documents() .search({ q: query, @@ -223,9 +219,8 @@ export class TypesenseRepository implements ISearchRepository { } async searchAssets(query: string, filters: SearchFilter): Promise> { - const alias = await this.client.aliases(SearchCollection.ASSETS).retrieve(); const results = await this.client - .collections(alias.collection_name) + .collections(assetSchema.name) .documents() .search({ q: query, @@ -248,12 +243,10 @@ export class TypesenseRepository implements ISearchRepository { } async vectorSearch(input: number[], filters: SearchFilter): Promise> { - const alias = await this.client.aliases(SearchCollection.ASSETS).retrieve(); - const { results } = await this.client.multiSearch.perform({ searches: [ { - collection: alias.collection_name, + collection: assetSchema.name, q: '*', vector_query: `smartInfo.clipEmbedding:([${input.join(',')}], k:100)`, per_page: 250,