add Annotation.findvalue index (used by findClips)

This commit is contained in:
j 2016-06-30 02:40:01 +02:00
parent b63024df02
commit b6e4d33a43
2 changed files with 3 additions and 2 deletions

View file

@ -72,7 +72,7 @@ def get_matches(obj, model, layer_type, qs=None):
name = name.lower() name = name.lower()
name = ox.decode_html(name) name = ox.decode_html(name)
name = unicodedata.normalize('NFKD', name).lower() 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) matches.append(a.id)
break break
if not matches: if not matches:
@ -96,7 +96,7 @@ class Annotation(models.Model):
layer = models.CharField(max_length=255, db_index=True) layer = models.CharField(max_length=255, db_index=True)
value = models.TextField() 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) sortvalue = models.CharField(max_length=1000, null=True, blank=True, db_index=True)
languages = models.CharField(max_length=255, null=True, blank=True) languages = models.CharField(max_length=255, null=True, blank=True)

View file

@ -37,6 +37,7 @@ class Command(BaseCommand):
for table, column in ( for table, column in (
(models.ItemFind._meta.db_table, 'value'), # Item Find (models.ItemFind._meta.db_table, 'value'), # Item Find
(models.Clip._meta.db_table, 'findvalue'), # Clip 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 (entity.models.Find._meta.db_table, 'value'), # Entity Find
): ):
cursor = connection.cursor() cursor = connection.cursor()