Skip to content

Commit

Permalink
Add full text search index by entity annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorjerse committed Feb 14, 2024
1 parent 46098d3 commit 8875804
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions resolwe/flow/migrations/triggers_entity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CREATE OR REPLACE FUNCTION generate_resolwe_entity_search(entity flow_entity)
DECLARE
owners users_result;
contributor users_result;
annotation_values users_result;
flat_descriptor text;
search tsvector;
BEGIN
Expand All @@ -26,6 +27,12 @@ CREATE OR REPLACE FUNCTION generate_resolwe_entity_search(entity flow_entity)
FROM auth_user
WHERE id = entity.contributor_id;

SELECT
_value -> 'label' values
INTO annotation_values
FROM flow_annotationvalue
WHERE entity_id = entity.id;

SELECT COALESCE(flatten_descriptor_values(entity.descriptor), '') INTO flat_descriptor;

SELECT
Expand Down Expand Up @@ -53,6 +60,8 @@ CREATE OR REPLACE FUNCTION generate_resolwe_entity_search(entity flow_entity)
setweight(to_tsvector('simple', COALESCE(owners.last_names, '')), 'B') ||
-- Entity tags.
setweight(to_tsvector('simple', array_to_string(entity.tags, ' ')), 'B') ||
-- Entity annotations.
setweight(to_tsvector('simple', COALESCE(annotation_values.values, '')), 'C')

INTO search;

Expand Down

0 comments on commit 8875804

Please sign in to comment.