-
-
Notifications
You must be signed in to change notification settings - Fork 4
feat(search)!: add search vectors for all supported languages #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sthelemann
wants to merge
2
commits into
main
Choose a base branch
from
feat/search/multi-language
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+319
−59
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| BEGIN; | ||
|
|
||
| CREATE TABLE vibetype.event_search_vector ( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Introducing a new table makes the availability of search vectors more flexible which can be a good or bad thing. Right now I'd like to rely on search vectors to be available / not null for all supported languages to prevent confusion when data is missing partly. |
||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| event_id UUID REFERENCES vibetype.event(id) ON DELETE SET NULL, | ||
| language vibetype.language NOT NULL, | ||
| search_vector TSVECTOR, | ||
|
|
||
| UNIQUE (event_id, language) | ||
| ); | ||
|
|
||
| COMMENT ON TABLE vibetype.event_search_vector IS E'@omit create,update,delete\nA language-specific search vector for an event.'; | ||
| COMMENT ON COLUMN vibetype.event_search_vector.id IS 'The records''s internal id.'; | ||
| COMMENT ON COLUMN vibetype.event_search_vector.event_id IS 'The reference to the event.'; | ||
| COMMENT ON COLUMN vibetype.event_search_vector.language IS 'The language associated with the search vector.'; | ||
| COMMENT ON COLUMN vibetype.event_search_vector.search_vector IS 'A vector used for full-text search on events.'; | ||
|
|
||
| CREATE INDEX idx_event_search_vector ON vibetype.event_search_vector USING gin (search_vector); | ||
|
|
||
| COMMENT ON INDEX vibetype.idx_event_search_vector IS 'GIN index on the search vector to improve full-text search performance.'; | ||
|
|
||
| GRANT SELECT ON TABLE vibetype.event_search_vector TO vibetype_anonymous; | ||
| GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vibetype.event_search_vector TO vibetype_account; | ||
|
|
||
| CREATE POLICY event_search_vector_select ON vibetype.event_search_vector FOR SELECT | ||
| USING ( | ||
| event_id IN (SELECT id FROM vibetype_private.event_policy_select()) | ||
| ); | ||
|
|
||
| COMMIT; | ||
This file contains hidden or 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 hidden or 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,6 @@ | ||
| BEGIN; | ||
|
|
||
| DROP INDEX vibetype.idx_event_search_vector; | ||
| DROP TABLE vibetype.event_search_vector; | ||
|
|
||
| COMMIT; |
This file contains hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| BEGIN; | ||
|
|
||
| SELECT id, | ||
| event_id, | ||
| language, | ||
| search_vector | ||
| FROM vibetype.event_search_vector WHERE FALSE; | ||
|
|
||
| \set role_service_vibetype_username `cat /run/secrets/postgres_role_service_vibetype_username` | ||
| SET local role.vibetype_username TO :'role_service_vibetype_username'; | ||
|
|
||
| DO $$ | ||
| BEGIN | ||
| ASSERT (SELECT pg_catalog.has_table_privilege('vibetype_account', 'vibetype.event_search_vector', 'SELECT')); | ||
| ASSERT (SELECT pg_catalog.has_table_privilege('vibetype_account', 'vibetype.event_search_vector', 'INSERT')); | ||
| ASSERT (SELECT pg_catalog.has_table_privilege('vibetype_account', 'vibetype.event_search_vector', 'UPDATE')); | ||
| ASSERT (SELECT pg_catalog.has_table_privilege('vibetype_account', 'vibetype.event_search_vector', 'DELETE')); | ||
| ASSERT (SELECT pg_catalog.has_table_privilege('vibetype_anonymous', 'vibetype.event_search_vector', 'SELECT')); | ||
| ASSERT NOT (SELECT pg_catalog.has_table_privilege('vibetype_anonymous', 'vibetype.event_search_vector', 'INSERT')); | ||
| ASSERT NOT (SELECT pg_catalog.has_table_privilege('vibetype_anonymous', 'vibetype.event_search_vector', 'UPDATE')); | ||
| ASSERT NOT (SELECT pg_catalog.has_table_privilege('vibetype_anonymous', 'vibetype.event_search_vector', 'DELETE')); | ||
| ASSERT NOT (SELECT pg_catalog.has_table_privilege(current_setting('role.vibetype_username'), 'vibetype.event_search_vector', 'SELECT')); | ||
| ASSERT NOT (SELECT pg_catalog.has_table_privilege(current_setting('role.vibetype_username'), 'vibetype.event_search_vector', 'INSERT')); | ||
| ASSERT NOT (SELECT pg_catalog.has_table_privilege(current_setting('role.vibetype_username'), 'vibetype.event_search_vector', 'UPDATE')); | ||
| ASSERT NOT (SELECT pg_catalog.has_table_privilege(current_setting('role.vibetype_username'), 'vibetype.event_search_vector', 'DELETE')); | ||
| END $$; | ||
|
|
||
| ROLLBACK; | ||
|
|
||
| ROLLBACK; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.