fix tags indexing (final)
This commit is contained in:
parent
35673f9ad0
commit
d97972a3ef
|
|
@ -143,6 +143,8 @@ class EstablishmentDocument(Document):
|
||||||
'weekday_display': fields.KeywordField(attr='get_weekday_display'),
|
'weekday_display': fields.KeywordField(attr='get_weekday_display'),
|
||||||
'closed_at': fields.KeywordField(attr='closed_at_str'),
|
'closed_at': fields.KeywordField(attr='closed_at_str'),
|
||||||
'opening_at': fields.KeywordField(attr='opening_at_str'),
|
'opening_at': fields.KeywordField(attr='opening_at_str'),
|
||||||
|
# 'closed_at_datetime': fields.DateField(attr='closed_at'),
|
||||||
|
# 'opening_at_datetime': fields.DateField(attr='opening_at'),
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
address = fields.ObjectField(
|
address = fields.ObjectField(
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from configuration.models import TranslationSettings
|
from configuration.models import TranslationSettings
|
||||||
from location.models import Country
|
from location.models import Country
|
||||||
from elasticsearch_dsl.utils import AttrDict
|
from utils.models import IndexJSON
|
||||||
from search_indexes.utils import OBJECT_FIELD_PROPERTIES
|
|
||||||
|
|
||||||
|
|
||||||
class TagQuerySet(models.QuerySet):
|
class TagQuerySet(models.QuerySet):
|
||||||
|
|
@ -52,8 +51,10 @@ class Tag(models.Model):
|
||||||
@property
|
@property
|
||||||
def label_indexing(self):
|
def label_indexing(self):
|
||||||
base_dict = self.translation.text if self.translation and isinstance(self.translation.text, dict) else {}
|
base_dict = self.translation.text if self.translation and isinstance(self.translation.text, dict) else {}
|
||||||
dict_to_index = {locale: base_dict.get(locale) for locale in OBJECT_FIELD_PROPERTIES}
|
index = IndexJSON()
|
||||||
return AttrDict(dict_to_index)
|
for k, v in base_dict.items():
|
||||||
|
setattr(index, k, v)
|
||||||
|
return index
|
||||||
|
|
||||||
objects = TagQuerySet.as_manager()
|
objects = TagQuerySet.as_manager()
|
||||||
|
|
||||||
|
|
@ -159,8 +160,10 @@ class TagCategory(models.Model):
|
||||||
@property
|
@property
|
||||||
def label_indexing(self):
|
def label_indexing(self):
|
||||||
base_dict = self.translation.text if self.translation and isinstance(self.translation.text, dict) else {}
|
base_dict = self.translation.text if self.translation and isinstance(self.translation.text, dict) else {}
|
||||||
dict_to_index = {locale: base_dict.get(locale) for locale in OBJECT_FIELD_PROPERTIES.keys()}
|
index = IndexJSON()
|
||||||
return AttrDict(dict_to_index)
|
for k, v in base_dict.items():
|
||||||
|
setattr(index, k, v)
|
||||||
|
return index
|
||||||
|
|
||||||
objects = TagCategoryQuerySet.as_manager()
|
objects = TagCategoryQuerySet.as_manager()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user