diff --git a/apps/search_indexes/views.py b/apps/search_indexes/views.py index a40b13ed..85bd7c01 100644 --- a/apps/search_indexes/views.py +++ b/apps/search_indexes/views.py @@ -89,10 +89,6 @@ class EstablishmentDocumentViewSet(BaseDocumentViewSet): search_fields = { 'name': {'fuzziness': 'auto:2,5', 'boost': 4}, - 'transliterated_name': {'fuzziness': 'auto:2,5', - 'boost': 3}, - 'index_name': {'fuzziness': 'auto:2,5', - 'boost': 2}, 'description': {'fuzziness': 'auto:2,5'}, } translated_search_fields = ( @@ -199,7 +195,7 @@ class ProductDocumentViewSet(BaseDocumentViewSet): """Product document ViewSet.""" document = ProductDocument - lookup_field = 'slug' + # lookup_field = 'slug' pagination_class = ProjectMobilePagination permission_classes = (permissions.AllowAny,) serializer_class = serializers.ProductDocumentSerializer @@ -212,8 +208,8 @@ class ProductDocumentViewSet(BaseDocumentViewSet): filter_backends = [ FilteringFilterBackend, filters.CustomSearchFilterBackend, - GeoSpatialFilteringFilterBackend, - DefaultOrderingFilterBackend, + # GeoSpatialFilteringFilterBackend, +# DefaultOrderingFilterBackend, ] search_fields = { @@ -221,10 +217,9 @@ class ProductDocumentViewSet(BaseDocumentViewSet): 'boost': 4}, 'transliterated_name': {'fuzziness': 'auto:2,5', 'boost': 3}, - 'index_name': {'fuzziness': 'auto:2,5', - 'boost': 2}, 'description': {'fuzziness': 'auto:2,5'}, } + translated_search_fields = ( 'description', ) @@ -248,9 +243,6 @@ class ProductDocumentViewSet(BaseDocumentViewSet): 'for_establishment': { 'field': 'establishment.slug', }, - 'type': { - 'field': 'product_type.index_name', - }, 'product_type': { 'field': 'product_type.index_name', }, @@ -262,5 +254,5 @@ class ProductDocumentViewSet(BaseDocumentViewSet): ] } } - geo_spatial_filter_fields = { - } \ No newline at end of file + # geo_spatial_filter_fields = { + # } \ No newline at end of file diff --git a/apps/tag/filters.py b/apps/tag/filters.py index 0b1fb829..08d14e94 100644 --- a/apps/tag/filters.py +++ b/apps/tag/filters.py @@ -31,13 +31,18 @@ class TagCategoryFilterSet(TagsBaseFilterSet): """TagCategory filterset.""" establishment_type = filters.CharFilter(method='by_establishment_type') + product_type = filters.CharFilter(method='by_product_type') class Meta: """Meta class.""" model = models.TagCategory fields = ('type', - 'establishment_type', ) + 'establishment_type', + 'product_type', ) + + def by_product_type(self, queryset, name, value): + return queryset.by_product_type(value) # todo: filter by establishment type def by_establishment_type(self, queryset, name, value): diff --git a/apps/tag/models.py b/apps/tag/models.py index a35425e8..2505b9ca 100644 --- a/apps/tag/models.py +++ b/apps/tag/models.py @@ -100,6 +100,10 @@ class TagCategoryQuerySet(models.QuerySet): """Filter by establishment type index name.""" return self.filter(establishment_types__index_name=index_name) + def by_product_type(self, index_name): + """Filter by product type index name.""" + return self.filter(product_types__index_name=index_name) + def with_tags(self, switcher=True): """Filter by existing tags.""" return self.exclude(tags__isnull=switcher)