"""Establishment app documents.""" from django.conf import settings from django_elasticsearch_dsl import Document, Index, fields from search_indexes.utils import OBJECT_FIELD_PROPERTIES from establishment import models EstablishmentIndex = Index(settings.ELASTICSEARCH_INDEX_NAMES.get(__name__, 'establishment')) EstablishmentIndex.settings(number_of_shards=1, number_of_replicas=1) @EstablishmentIndex.doc_type class EstablishmentDocument(Document): """Establishment document.""" name = fields.ObjectField(properties=OBJECT_FIELD_PROPERTIES) description = fields.ObjectField(properties=OBJECT_FIELD_PROPERTIES) class Django: model = models.Establishment fields = ( 'id', 'public_mark', 'toque_number', 'price_level', ) def prepare_name(self, instance): return instance.name def prepare_description(self, instance): return instance.description