Skip to content

Commit

Permalink
Check if a field isn't used in title for mark
Browse files Browse the repository at this point in the history
  • Loading branch information
reiterl committed Oct 13, 2023
1 parent 6fb3d0b commit d647b71
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class GlobalSearchService {
const result = results[fqid];
if (result.matched_by) {
for (const field of Object.keys(result.matched_by)) {
if (result.content[field] && field != `title`) {
if (result.content[field] && !this.isTitleField(collectionFromFqid(fqid), field)) {
for (const word of result.matched_by[field]) {
result.content[field] = `${result.content[field]}`.replace(
new RegExp(word, `gi`),
Expand All @@ -69,6 +69,14 @@ export class GlobalSearchService {
}
}

private isTitleField(collection: string, field: string): boolean {
if (collection === `user`) {
return [`first_name`, `last_name`, `username`, `title`].includes(field);
} else {
return [`name`, `title`].includes(field);
}
}

private updateScores(results: GlobalSearchResponse): void {
for (const fqid of Object.keys(results)) {
this.updateScore(fqid, results[fqid].score || 0, results);
Expand Down

0 comments on commit d647b71

Please sign in to comment.