From bd7ba611fc399ff5b6dd9eda0f3d8269f2616b79 Mon Sep 17 00:00:00 2001 From: Kuroshini Date: Thu, 10 Oct 2019 14:28:42 +0300 Subject: [PATCH 1/2] Fix imports issue --- apps/establishment/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/establishment/models.py b/apps/establishment/models.py index 43bc2f94..4b4cbbea 100644 --- a/apps/establishment/models.py +++ b/apps/establishment/models.py @@ -11,7 +11,7 @@ from django.db import models from django.db.models import When, Case, F, ExpressionWrapper, Subquery, Q from django.utils import timezone from django.utils.translation import gettext_lazy as _ -from elasticsearch_dsl import Q +from elasticsearch_dsl import Q as Elastic_Q from phonenumber_field.modelfields import PhoneNumberField from collection.models import Collection @@ -103,8 +103,8 @@ class EstablishmentQuerySet(models.QuerySet): """Search text via ElasticSearch.""" from search_indexes.documents import EstablishmentDocument search = EstablishmentDocument.search().filter( - Q('match', name=value) | - Q('match', **{f'description.{locale}': value}) + Elastic_Q('match', name=value) | + Elastic_Q('match', **{f'description.{locale}': value}) ).execute() ids = [result.meta.id for result in search] return self.filter(id__in=ids) From bb41f00451cfceffcf9f3a98962ae6d2cb5ada9a Mon Sep 17 00:00:00 2001 From: evgeniy-st Date: Thu, 10 Oct 2019 14:42:42 +0300 Subject: [PATCH 2/2] hide es search --- apps/establishment/models.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/establishment/models.py b/apps/establishment/models.py index 4b4cbbea..fe81d9ef 100644 --- a/apps/establishment/models.py +++ b/apps/establishment/models.py @@ -11,7 +11,6 @@ from django.db import models from django.db.models import When, Case, F, ExpressionWrapper, Subquery, Q from django.utils import timezone from django.utils.translation import gettext_lazy as _ -from elasticsearch_dsl import Q as Elastic_Q from phonenumber_field.modelfields import PhoneNumberField from collection.models import Collection @@ -99,15 +98,15 @@ class EstablishmentQuerySet(models.QuerySet): else: return self.none() - def es_search(self, value, locale=None): - """Search text via ElasticSearch.""" - from search_indexes.documents import EstablishmentDocument - search = EstablishmentDocument.search().filter( - Elastic_Q('match', name=value) | - Elastic_Q('match', **{f'description.{locale}': value}) - ).execute() - ids = [result.meta.id for result in search] - return self.filter(id__in=ids) + # def es_search(self, value, locale=None): + # """Search text via ElasticSearch.""" + # from search_indexes.documents import EstablishmentDocument + # search = EstablishmentDocument.search().filter( + # Elastic_Q('match', name=value) | + # Elastic_Q('match', **{f'description.{locale}': value}) + # ).execute() + # ids = [result.meta.id for result in search] + # return self.filter(id__in=ids) def by_country_code(self, code): """Return establishments by country code"""