diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-09-18 12:16:31 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-10-24 12:06:08 +0200 |
commit | f0e8bab97707a729bada5b7fa17d81202ab8eaa8 (patch) | |
tree | a629ede5e35c43da1ecf9d961d95d8e3e750c9a1 | |
parent | e4886af839af1194d0153c99234751d7cd4fde27 (diff) | |
download | Ishtar-f0e8bab97707a729bada5b7fa17d81202ab8eaa8.tar.bz2 Ishtar-f0e8bab97707a729bada5b7fa17d81202ab8eaa8.zip |
Unidecode "simple" fields for search index
-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: |