summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-10-12 16:33:24 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-10-12 16:33:24 +0200
commitd644ad71585c5ebf2113f2c538c38c775b334228 (patch)
tree66df3422b057c773b3088d2746323389bedad517 /ishtar_common
parent88f2d0dc710674aa5017271b1d558a1da2ecdd1e (diff)
downloadIshtar-d644ad71585c5ebf2113f2c538c38c775b334228.tar.bz2
Ishtar-d644ad71585c5ebf2113f2c538c38c775b334228.zip
Search vectors manage integration of parent vectors (refs #2912)
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 915415416..ac5c29a0f 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -924,6 +924,7 @@ class FullSearch(models.Model):
BASE_SEARCH_VECTORS = []
INT_SEARCH_VECTORS = []
M2M_SEARCH_VECTORS = []
+ PARENT_SEARCH_VECTORS = []
class Meta:
abstract = True
@@ -968,6 +969,15 @@ class FullSearch(models.Model):
search_vectors.append(
"'{}':1".format(q.all()[0][INT_SEARCH_VECTOR]))
+ # copy parent vector fields
+ for PARENT_SEARCH_VECTOR in self.PARENT_SEARCH_VECTORS:
+ parent = getattr(self, PARENT_SEARCH_VECTOR)
+ if hasattr(parent, 'all'): # m2m
+ for p in parent.all():
+ search_vectors.append(p.search_vector)
+ else:
+ search_vectors.append(parent.search_vector)
+
# query "simple" fields
q = base_q.annotate(
search=SearchVector(