diff options
-rw-r--r-- | ishtar_common/models.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 15d6a0ba9..5be06fd32 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1262,16 +1262,15 @@ class FullSearch(models.Model): if self.BASE_SEARCH_VECTORS: # query "simple" fields - q = base_q.annotate( - search=SearchVector( - *self.BASE_SEARCH_VECTORS, - config=settings.ISHTAR_SEARCH_LANGUAGE - )).values('search') - search_vectors.append( - unidecode( - q.all()[0]['search'].decode('utf-8') - ) - ) + q = base_q.values(*self.BASE_SEARCH_VECTORS) + res = q.all()[0] + for base_search_vector in self.BASE_SEARCH_VECTORS: + data = res[base_search_vector] + data = unidecode(unicode(data)) + with connection.cursor() as cursor: + cursor.execute("SELECT to_tsvector(%s)", [data]) + row = cursor.fetchone() + search_vectors.append(row[0]) if self.PROPERTY_SEARCH_VECTORS: for attr in self.PROPERTY_SEARCH_VECTORS: |