summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index bd800181f..38e58955b 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1089,6 +1089,7 @@ class FullSearch(models.Model):
search_vector = SearchVectorField(_("Search vector"), blank=True, null=True,
help_text=_("Auto filled at save"))
BASE_SEARCH_VECTORS = []
+ PROPERTY_SEARCH_VECTORS = []
INT_SEARCH_VECTORS = []
M2M_SEARCH_VECTORS = []
PARENT_SEARCH_VECTORS = []
@@ -1122,6 +1123,7 @@ class FullSearch(models.Model):
return
if not self.BASE_SEARCH_VECTORS and not self.M2M_SEARCH_VECTORS \
and not self.INT_SEARCH_VECTORS \
+ and not self.PROPERTY_SEARCH_VECTORS \
and not self.PARENT_SEARCH_VECTORS:
logger.warning("No search_vectors defined for {}".format(
self.__class__))
@@ -1191,6 +1193,19 @@ class FullSearch(models.Model):
)
)
+ if self.PROPERTY_SEARCH_VECTORS:
+ for attr in self.PROPERTY_SEARCH_VECTORS:
+ data = getattr(self, attr)
+ if callable(data):
+ data = data()
+ if not data:
+ continue
+ data = unicode(data)
+ with connection.cursor() as cursor:
+ cursor.execute("SELECT to_tsvector(%s)", [data])
+ row = cursor.fetchone()
+ search_vectors.append(row[0])
+
if hasattr(self, 'data') and self.data:
content_type = ContentType.objects.get_for_model(self)
for json_field in JsonDataField.objects.filter(