Fix extra tags indexing

This commit is contained in:
Kuroshini 2019-12-02 21:32:03 +03:00
parent 140ba040e7
commit e981b48fa0
2 changed files with 11 additions and 5 deletions

View File

@ -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."""

View File

@ -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()