diff --git a/resolwe/flow/migrations/triggers_entity.sql b/resolwe/flow/migrations/triggers_entity.sql index 8d5b80e6e..3810c98fe 100644 --- a/resolwe/flow/migrations/triggers_entity.sql +++ b/resolwe/flow/migrations/triggers_entity.sql @@ -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 @@ -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 @@ -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;