This repository has been archived by the owner on Apr 12, 2023. It is now read-only.
forked from ggaulard/Zenika-Resume
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search is now powered by Postgres full-text search capabilities.
- Loading branch information
Showing
7 changed files
with
126 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
[] | ||
- function: | ||
schema: public | ||
name: search_resume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
drop function if exists search_resume; | ||
|
||
drop index if exists resume_full_text_search_idx; | ||
|
||
alter table resume | ||
drop column full_text_search_vector; | ||
|
||
drop function if exists to_tsvector_multilang; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
create function to_tsvector_multilang(text) returns tsvector as $$ | ||
select to_tsvector('french', $1) || | ||
to_tsvector('english', $1) | ||
$$ language sql immutable; | ||
|
||
alter table resume | ||
add column full_text_search_vector tsvector | ||
generated always as ( | ||
setweight(to_tsvector('simple', metadata), 'A') | ||
|| setweight(to_tsvector_multilang(content), 'C') | ||
) stored; | ||
|
||
create index resume_full_text_search_idx on resume using gin(full_text_search_vector); | ||
|
||
create function search_resume(search text) returns setof resume as $$ | ||
select resume.* | ||
from latest_resume | ||
join resume using (uuid, version_date) | ||
where resume.full_text_search_vector @@ websearch_to_tsquery(search) | ||
order by | ||
ts_rank_cd(resume.full_text_search_vector, websearch_to_tsquery(search)) desc, | ||
resume.last_modified desc | ||
$$ language sql stable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters