From b6e4d33a430c31f5f7af9211d0918b5851be0611 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 30 Jun 2016 02:40:01 +0200 Subject: [PATCH] add Annotation.findvalue index (used by findClips) --- pandora/annotation/models.py | 4 ++-- pandora/item/management/commands/sqlfindindex.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 51b087708..7fa4ff05c 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -72,7 +72,7 @@ def get_matches(obj, model, layer_type, qs=None): name = name.lower() name = ox.decode_html(name) name = unicodedata.normalize('NFKD', name).lower() - if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\'"\)\]\-\/\s]|$))'%re.escape(name)).findall(value)): + if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\'"\)\]\-\/\s]|$))' % re.escape(name)).findall(value)): matches.append(a.id) break if not matches: @@ -96,7 +96,7 @@ class Annotation(models.Model): layer = models.CharField(max_length=255, db_index=True) value = models.TextField() - findvalue = models.TextField(null=True) + findvalue = models.TextField(null=True, db_index=settings.DB_GIN_TRGM) sortvalue = models.CharField(max_length=1000, null=True, blank=True, db_index=True) languages = models.CharField(max_length=255, null=True, blank=True) diff --git a/pandora/item/management/commands/sqlfindindex.py b/pandora/item/management/commands/sqlfindindex.py index 8a2cb77db..3823a83b7 100644 --- a/pandora/item/management/commands/sqlfindindex.py +++ b/pandora/item/management/commands/sqlfindindex.py @@ -37,6 +37,7 @@ class Command(BaseCommand): for table, column in ( (models.ItemFind._meta.db_table, 'value'), # Item Find (models.Clip._meta.db_table, 'findvalue'), # Clip Find + (models.Annotation._meta.db_table, 'findvalue'), # Annotation Find (entity.models.Find._meta.db_table, 'value'), # Entity Find ): cursor = connection.cursor()