From e981b48fa0f7822e8a682a7ee7471414a750af5d Mon Sep 17 00:00:00 2001 From: Kuroshini Date: Mon, 2 Dec 2019 21:32:03 +0300 Subject: [PATCH] Fix extra tags indexing --- apps/establishment/models.py | 8 ++++++++ apps/search_indexes/documents/establishment.py | 8 +++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/establishment/models.py b/apps/establishment/models.py index 74d40921..e270832b 100644 --- a/apps/establishment/models.py +++ b/apps/establishment/models.py @@ -602,6 +602,14 @@ class Establishment(GalleryModelMixin, ProjectBaseMixin, URLImageMixin, if qs.exists(): return qs.first().image + @property + def restaurant_category_indexing(self): + return self.tags.filter(category__index_name='category') + + @property + def restaurant_cuisine_indexing(self): + return self.tags.filter(category__index_name='cuisine') + class EstablishmentNoteQuerySet(models.QuerySet): """QuerySet for model EstablishmentNote.""" diff --git a/apps/search_indexes/documents/establishment.py b/apps/search_indexes/documents/establishment.py index 5e14888c..9cfc27d3 100644 --- a/apps/search_indexes/documents/establishment.py +++ b/apps/search_indexes/documents/establishment.py @@ -56,7 +56,7 @@ class EstablishmentDocument(Document): properties=OBJECT_FIELD_PROPERTIES), 'value': fields.KeywordField(), }, - multi=True) + multi=True, attr='restaurant_category_indexing') restaurant_cuisine = fields.ObjectField( properties={ 'id': fields.IntegerField(attr='id'), @@ -64,7 +64,7 @@ class EstablishmentDocument(Document): properties=OBJECT_FIELD_PROPERTIES), 'value': fields.KeywordField(), }, - multi=True) + multi=True, attr='restaurant_cuisine_indexing') visible_tags = fields.ObjectField( properties={ 'id': fields.IntegerField(attr='id'), @@ -158,6 +158,4 @@ class EstablishmentDocument(Document): ) def get_queryset(self): - return super().get_queryset().with_es_related() \ - .with_certain_tag_category_related('category', 'restaurant_category') \ - .with_certain_tag_category_related('cuisine', 'restaurant_cuisine') + return super().get_queryset().with_es_related()