diff --git a/apps/server-asset-sg/src/app/search/asset-search-service.ts b/apps/server-asset-sg/src/app/search/asset-search-service.ts index 652438be..88d9cd90 100644 --- a/apps/server-asset-sg/src/app/search/asset-search-service.ts +++ b/apps/server-asset-sg/src/app/search/asset-search-service.ts @@ -133,16 +133,9 @@ export class AssetSearchService { query: { bool: { should: [ - { - multi_match: { - query, - fields: scope, - fuzziness: 'AUTO', - }, - }, { query_string: { - query: `*${query}*`, + query: normalizeFieldQuery(query), fields: scope, }, }, @@ -337,3 +330,11 @@ export class AssetSearchService { } } } + +const normalizeFieldQuery = (query: string): string => ( + query + .replace(/title(_*)public:/i, 'titlePublic:') + .replace(/title(_*)original:/i, 'titleOriginal:') + .replace(/contact(_*)ame:/i, 'contactNames:') + .replace(/sgs(_*)id:/i, 'sgsId:') +);