Skip to content

Commit

Permalink
update addSearchQuery to prioritize the title
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadPCh committed Sep 19, 2024
1 parent 7007987 commit 61524cd
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/resolvers/projectResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,22 @@ export class ProjectResolver {
// .addSelect('similarity(project.description, :searchTerm)', 'desc_slm')
// .addSelect('similarity(project.impactLocation, :searchTerm)', 'loc_slm')
// .setParameter('searchTerm', searchTerm)
.addSelect(
`(CASE
WHEN project.title %> :searchTerm THEN 1
ELSE 2
END)`,
'title_priority',
)
.andWhere(
new Brackets(qb => {
qb.where('project.title %> :searchTerm ', {
searchTerm,
})
.orWhere('project.description %> :searchTerm ', {
searchTerm,
})
.orWhere('project.impactLocation %> :searchTerm', {
searchTerm,
});
qb.where('project.title %> :searchTerm', { searchTerm })
.orWhere('project.description %> :searchTerm', { searchTerm })
.orWhere('project.impactLocation %> :searchTerm', { searchTerm });
}),
)
.orderBy('title_priority', 'ASC')
.setParameter('searchTerm', searchTerm)
);
}

Expand Down

0 comments on commit 61524cd

Please sign in to comment.