fix es for establishments
This commit is contained in:
parent
bebd1283c0
commit
1d9ee76a5c
|
|
@ -56,7 +56,4 @@ class GuideSerializer(serializers.ModelSerializer):
|
||||||
'name',
|
'name',
|
||||||
'start',
|
'start',
|
||||||
'end',
|
'end',
|
||||||
'parent',
|
|
||||||
'advertorials',
|
|
||||||
'collection'
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,9 @@ class ProductBackOfficeDetailSerializer(ProductDetailSerializer):
|
||||||
'available',
|
'available',
|
||||||
'product_type',
|
'product_type',
|
||||||
'establishment',
|
'establishment',
|
||||||
'wine_region',
|
# todo: need fix
|
||||||
'wine_sub_region',
|
# 'wine_region',
|
||||||
|
# 'wine_sub_region',
|
||||||
'wine_village',
|
'wine_village',
|
||||||
'state',
|
'state',
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -83,33 +83,59 @@ class EstablishmentDocument(Document):
|
||||||
multi=True)
|
multi=True)
|
||||||
products = fields.ObjectField(
|
products = fields.ObjectField(
|
||||||
properties={
|
properties={
|
||||||
'wine_region': fields.ObjectField(properties={
|
'wine_origins': fields.ListField(
|
||||||
'id': fields.IntegerField(),
|
fields.ObjectField(
|
||||||
'name': fields.KeywordField(),
|
properties={
|
||||||
'country': fields.ObjectField(properties={
|
'wine_region': fields.ObjectField(properties={
|
||||||
'id': fields.IntegerField(),
|
'id': fields.IntegerField(),
|
||||||
'name': fields.ObjectField(attr='name_indexing',
|
'name': fields.KeywordField(),
|
||||||
properties=OBJECT_FIELD_PROPERTIES),
|
'country': fields.ObjectField(properties={
|
||||||
'code': fields.KeywordField(),
|
'id': fields.IntegerField(),
|
||||||
}),
|
'name': fields.ObjectField(attr='name_indexing',
|
||||||
# 'coordinates': fields.GeoPointField(),
|
properties=OBJECT_FIELD_PROPERTIES),
|
||||||
'description': fields.ObjectField(attr='description_indexing', properties=OBJECT_FIELD_PROPERTIES),
|
'code': fields.KeywordField(),
|
||||||
}),
|
}),
|
||||||
|
# 'coordinates': fields.GeoPointField(),
|
||||||
|
'description': fields.ObjectField(attr='description_indexing',
|
||||||
|
properties=OBJECT_FIELD_PROPERTIES)
|
||||||
|
|
||||||
|
}),
|
||||||
|
'wine_sub_region': fields.ObjectField(properties={
|
||||||
|
'id': fields.IntegerField(),
|
||||||
|
'name': fields.KeywordField(),
|
||||||
|
}),
|
||||||
|
})),
|
||||||
'wine_colors': fields.ObjectField(
|
'wine_colors': fields.ObjectField(
|
||||||
properties={
|
properties={
|
||||||
'id': fields.IntegerField(),
|
'id': fields.IntegerField(),
|
||||||
'label': fields.ObjectField(attr='label_indexing', properties=OBJECT_FIELD_PROPERTIES),
|
'label': fields.ObjectField(attr='label_indexing', properties=OBJECT_FIELD_PROPERTIES),
|
||||||
'value': fields.KeywordField(),
|
'value': fields.KeywordField(),
|
||||||
},
|
},
|
||||||
multi=True,
|
multi=True,)},
|
||||||
),
|
|
||||||
'wine_sub_region': fields.ObjectField(properties={
|
|
||||||
'id': fields.IntegerField(),
|
|
||||||
'name': fields.KeywordField(),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
multi=True
|
multi=True
|
||||||
)
|
)
|
||||||
|
wine_origins = fields.ListField(
|
||||||
|
fields.ObjectField(
|
||||||
|
properties={
|
||||||
|
'wine_region': fields.ObjectField(properties={
|
||||||
|
'id': fields.IntegerField(),
|
||||||
|
'name': fields.KeywordField(),
|
||||||
|
'country': fields.ObjectField(properties={
|
||||||
|
'id': fields.IntegerField(),
|
||||||
|
'name': fields.ObjectField(attr='name_indexing',
|
||||||
|
properties=OBJECT_FIELD_PROPERTIES),
|
||||||
|
'code': fields.KeywordField(),
|
||||||
|
}),
|
||||||
|
# 'coordinates': fields.GeoPointField(),
|
||||||
|
'description': fields.ObjectField(attr='description_indexing',
|
||||||
|
properties=OBJECT_FIELD_PROPERTIES)
|
||||||
|
|
||||||
|
}),
|
||||||
|
'wine_sub_region': fields.ObjectField(properties={
|
||||||
|
'id': fields.IntegerField(),
|
||||||
|
'name': fields.KeywordField(),
|
||||||
|
})})
|
||||||
|
)
|
||||||
schedule = fields.ListField(fields.ObjectField(
|
schedule = fields.ListField(fields.ObjectField(
|
||||||
properties={
|
properties={
|
||||||
'id': fields.IntegerField(attr='id'),
|
'id': fields.IntegerField(attr='id'),
|
||||||
|
|
|
||||||
|
|
@ -83,22 +83,28 @@ class ProductDocument(Document):
|
||||||
},
|
},
|
||||||
multi=True,
|
multi=True,
|
||||||
)
|
)
|
||||||
wine_region = fields.ObjectField(properties={
|
wine_origins = fields.ListField(
|
||||||
'id': fields.IntegerField(),
|
fields.ObjectField(
|
||||||
'name': fields.KeywordField(),
|
properties={
|
||||||
'country': fields.ObjectField(properties={
|
'wine_region': fields.ObjectField(properties={
|
||||||
'id': fields.IntegerField(),
|
'id': fields.IntegerField(),
|
||||||
'name': fields.ObjectField(attr='name_indexing',
|
'name': fields.KeywordField(),
|
||||||
properties=OBJECT_FIELD_PROPERTIES),
|
'country': fields.ObjectField(properties={
|
||||||
'code': fields.KeywordField(),
|
'id': fields.IntegerField(),
|
||||||
}),
|
'name': fields.ObjectField(attr='name_indexing',
|
||||||
# 'coordinates': fields.GeoPointField(),
|
properties=OBJECT_FIELD_PROPERTIES),
|
||||||
'description': fields.ObjectField(attr='description_indexing', properties=OBJECT_FIELD_PROPERTIES),
|
'code': fields.KeywordField(),
|
||||||
})
|
}),
|
||||||
wine_sub_region = fields.ObjectField(properties={
|
# 'coordinates': fields.GeoPointField(),
|
||||||
'id': fields.IntegerField(),
|
'description': fields.ObjectField(attr='description_indexing',
|
||||||
'name': fields.KeywordField(),
|
properties=OBJECT_FIELD_PROPERTIES)
|
||||||
})
|
|
||||||
|
}),
|
||||||
|
'wine_sub_region': fields.ObjectField(properties={
|
||||||
|
'id': fields.IntegerField(),
|
||||||
|
'name': fields.KeywordField(),
|
||||||
|
})})
|
||||||
|
)
|
||||||
classifications = fields.ObjectField( # TODO
|
classifications = fields.ObjectField( # TODO
|
||||||
properties={
|
properties={
|
||||||
'classification_type': fields.ObjectField(properties={}),
|
'classification_type': fields.ObjectField(properties={}),
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,16 @@ class WineRegionDocumentSerializer(serializers.Serializer):
|
||||||
return instance.wine_region if instance and instance.wine_region else None
|
return instance.wine_region if instance and instance.wine_region else None
|
||||||
|
|
||||||
|
|
||||||
|
class WineSubRegionDocumentSerializer(serializers.Serializer):
|
||||||
|
"""Wine region ES document serializer."""
|
||||||
|
|
||||||
|
id = serializers.IntegerField()
|
||||||
|
name = serializers.CharField()
|
||||||
|
|
||||||
|
def get_attribute(self, instance):
|
||||||
|
return instance.wine_sub_region if instance and instance.wine_sub_region else None
|
||||||
|
|
||||||
|
|
||||||
class TagDocumentSerializer(serializers.Serializer):
|
class TagDocumentSerializer(serializers.Serializer):
|
||||||
"""Tag ES document serializer,"""
|
"""Tag ES document serializer,"""
|
||||||
|
|
||||||
|
|
@ -223,6 +233,13 @@ class NewsDocumentSerializer(InFavoritesMixin, DocumentSerializer):
|
||||||
return get_translated_value(obj.subtitle)
|
return get_translated_value(obj.subtitle)
|
||||||
|
|
||||||
|
|
||||||
|
class WineOriginSerializer(serializers.Serializer):
|
||||||
|
"""Wine origin serializer."""
|
||||||
|
|
||||||
|
wine_region = WineRegionDocumentSerializer()
|
||||||
|
wine_sub_region = WineSubRegionDocumentSerializer(allow_null=True)
|
||||||
|
|
||||||
|
|
||||||
class EstablishmentDocumentSerializer(InFavoritesMixin, DocumentSerializer):
|
class EstablishmentDocumentSerializer(InFavoritesMixin, DocumentSerializer):
|
||||||
"""Establishment document serializer."""
|
"""Establishment document serializer."""
|
||||||
|
|
||||||
|
|
@ -234,6 +251,7 @@ class EstablishmentDocumentSerializer(InFavoritesMixin, DocumentSerializer):
|
||||||
restaurant_cuisine = TagsDocumentSerializer(many=True, allow_null=True)
|
restaurant_cuisine = TagsDocumentSerializer(many=True, allow_null=True)
|
||||||
artisan_category = TagsDocumentSerializer(many=True, allow_null=True)
|
artisan_category = TagsDocumentSerializer(many=True, allow_null=True)
|
||||||
schedule = ScheduleDocumentSerializer(many=True, allow_null=True)
|
schedule = ScheduleDocumentSerializer(many=True, allow_null=True)
|
||||||
|
wine_origins = WineOriginSerializer(many=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Meta class."""
|
"""Meta class."""
|
||||||
|
|
@ -259,6 +277,7 @@ class EstablishmentDocumentSerializer(InFavoritesMixin, DocumentSerializer):
|
||||||
'works_evening',
|
'works_evening',
|
||||||
'works_at_weekday',
|
'works_at_weekday',
|
||||||
'tz',
|
'tz',
|
||||||
|
'wine_origins',
|
||||||
# 'works_now',
|
# 'works_now',
|
||||||
# 'collections',
|
# 'collections',
|
||||||
# 'establishment_type',
|
# 'establishment_type',
|
||||||
|
|
@ -276,6 +295,7 @@ class ProductDocumentSerializer(InFavoritesMixin, DocumentSerializer):
|
||||||
grape_variety = TagDocumentSerializer(many=True)
|
grape_variety = TagDocumentSerializer(many=True)
|
||||||
product_type = ProductTypeDocumentSerializer(allow_null=True)
|
product_type = ProductTypeDocumentSerializer(allow_null=True)
|
||||||
establishment_detail = ProductEstablishmentDocumentSerializer(source='establishment', allow_null=True)
|
establishment_detail = ProductEstablishmentDocumentSerializer(source='establishment', allow_null=True)
|
||||||
|
wine_origins = WineOriginSerializer(many=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""Meta class."""
|
"""Meta class."""
|
||||||
|
|
@ -302,4 +322,5 @@ class ProductDocumentSerializer(InFavoritesMixin, DocumentSerializer):
|
||||||
'establishment_detail',
|
'establishment_detail',
|
||||||
'average_price',
|
'average_price',
|
||||||
'created',
|
'created',
|
||||||
|
'wine_origins',
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,15 @@ class EstablishmentDocumentViewSet(BaseDocumentViewSet):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'wine_region_id': {
|
'wine_region_id': {
|
||||||
'field': 'products.wine_region.id',
|
'field': 'wine_origins.wine_region.id',
|
||||||
|
'facet': TermsFacet,
|
||||||
|
'enabled': True,
|
||||||
|
'options': {
|
||||||
|
'size': utils.FACET_MAX_RESPONSE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'wine_sub_region_id': {
|
||||||
|
'field': 'wine_origins.wine_sub_region.id',
|
||||||
'facet': TermsFacet,
|
'facet': TermsFacet,
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
'options': {
|
'options': {
|
||||||
|
|
@ -213,14 +221,14 @@ class EstablishmentDocumentViewSet(BaseDocumentViewSet):
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'wine_region_id': {
|
'wine_region_id': {
|
||||||
'field': 'products.wine_region.id',
|
'field': 'wine_origins.wine_region.id',
|
||||||
'lookups': [
|
'lookups': [
|
||||||
constants.LOOKUP_QUERY_IN,
|
constants.LOOKUP_QUERY_IN,
|
||||||
constants.LOOKUP_QUERY_EXCLUDE,
|
constants.LOOKUP_QUERY_EXCLUDE,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'wine_sub_region_id': {
|
'wine_sub_region_id': {
|
||||||
'field': 'products.wine_sub_region_id',
|
'field': 'wine_origins.wine_sub_region.id',
|
||||||
'lookups': [
|
'lookups': [
|
||||||
constants.LOOKUP_QUERY_IN,
|
constants.LOOKUP_QUERY_IN,
|
||||||
constants.LOOKUP_QUERY_EXCLUDE,
|
constants.LOOKUP_QUERY_EXCLUDE,
|
||||||
|
|
@ -354,13 +362,21 @@ class ProductDocumentViewSet(BaseDocumentViewSet):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'wine_region_id': {
|
'wine_region_id': {
|
||||||
'field': 'wine_region.id',
|
'field': 'wine_origins.wine_region.id',
|
||||||
'enabled': True,
|
|
||||||
'facet': TermsFacet,
|
'facet': TermsFacet,
|
||||||
|
'enabled': True,
|
||||||
'options': {
|
'options': {
|
||||||
'size': utils.FACET_MAX_RESPONSE,
|
'size': utils.FACET_MAX_RESPONSE,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'wine_sub_region_id': {
|
||||||
|
'field': 'wine_origins.wine_sub_region.id',
|
||||||
|
'facet': TermsFacet,
|
||||||
|
'enabled': True,
|
||||||
|
'options': {
|
||||||
|
'size': utils.FACET_MAX_RESPONSE,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
translated_search_fields = (
|
translated_search_fields = (
|
||||||
|
|
@ -384,14 +400,14 @@ class ProductDocumentViewSet(BaseDocumentViewSet):
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'wine_region_id': {
|
'wine_region_id': {
|
||||||
'field': 'wine_region.id',
|
'field': 'wine_origins.wine_region.id',
|
||||||
'lookups': [
|
'lookups': [
|
||||||
constants.LOOKUP_QUERY_IN,
|
constants.LOOKUP_QUERY_IN,
|
||||||
constants.LOOKUP_QUERY_EXCLUDE,
|
constants.LOOKUP_QUERY_EXCLUDE,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'wine_sub_region_id': {
|
'wine_sub_region_id': {
|
||||||
'field': 'wine_sub_region_id',
|
'field': 'wine_origins.wine_sub_region.id',
|
||||||
'lookups': [
|
'lookups': [
|
||||||
constants.LOOKUP_QUERY_IN,
|
constants.LOOKUP_QUERY_IN,
|
||||||
constants.LOOKUP_QUERY_EXCLUDE,
|
constants.LOOKUP_QUERY_EXCLUDE,
|
||||||
|
|
@ -404,9 +420,9 @@ class ProductDocumentViewSet(BaseDocumentViewSet):
|
||||||
constants.LOOKUP_QUERY_EXCLUDE,
|
constants.LOOKUP_QUERY_EXCLUDE,
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'wine_from_country_code': {
|
# 'wine_from_country_code': {
|
||||||
'field': 'wine_region.country.code',
|
# 'field': 'wine_origins.wine_region.country.code',
|
||||||
},
|
# },
|
||||||
'for_establishment': {
|
'for_establishment': {
|
||||||
'field': 'establishment.slug',
|
'field': 'establishment.slug',
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user