Skip to content

Commit

Permalink
Fix search by field not working
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-va committed Jun 12, 2024
1 parent 1cb9416 commit e3f1638
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions apps/server-asset-sg/src/app/search/asset-search-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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:')
);

0 comments on commit e3f1638

Please sign in to comment.